Re: Can Plot, can't FindRoot - what gives?
- To: mathgroup at smc.vnet.net
- Subject: [mg97734] Re: Can Plot, can't FindRoot - what gives?
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Fri, 20 Mar 2009 02:38:42 -0500 (EST)
- References: <gpsrae$mm8$1@smc.vnet.net>
Aaron Fude wrote: > Hi, > > Here's my code for a model problem. I do not need a solution to this > simple problem, of course - I just need to understand why Mathematica > is giving me an error. > > f[c_] := ( > s = NDSolve[{ y'[x] == c - 1, y[0] == 0}, y, {x, 0, 2*Pi}]; > (Evaluate[y[x] /. s] /. x -> 2*Pi)[[1]] > ) > Plot[f[c], {c, 0, 10}] > f[1] > FindRoot[f[c] == 0, {c, 1}] > > I get a series of errors, the first of which is > NDSolve::ndnum: Encountered non-numerical value for a derivative at x > \== 0.` > > I'm on Win32 version 6. > Clear[f], then change f[c_] := ... to f[c_?NumericQ] := ...