Re: a bug in mathematica 5?
- To: mathgroup at smc.vnet.net
- Subject: [mg43212] Re: a bug in mathematica 5?
- From: "Alan" <infoNOSPAM at optioncity.net>
- Date: Tue, 19 Aug 2003 07:53:15 -0400 (EDT)
- References: <bh2714$hra$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Li-Xin Li" <lli at fas.harvard.edu> wrote in message news:bh2714$hra$1 at smc.vnet.net... > Is the following a bug in mathematica 5? > > I typed > sol[x_] := NDSolve[{y'[t] == x Sin[t] y[t], y[0.01] == 1}, > y, {t, 0.01, 10}] > u[x_] := ((y[1] /. sol[x])[[1]]) - 3 > > to define a function u[x]. It works, e.g. u[1] = -1.41648. > > Then, I typed > FindRoot[u[x] == 0, {x, 2, 3}] > to find the root for u[x] = 0. But this does not work. Instead, it > gives the following error messages: > > NDSolve::ndnum: Encountered non-numerical value for a derivative at > t==0.01`. > ReplaceAll::reps: {NDSolve[{y'[t] == x Sin[t] y[t], y[0.01] == 1}, > y, {t, 0.01, 10}]} is neither a list of replacement rules nor > a valid dispatch table, and so cannot be used for replacing. > FindRoot::ndnum: The function value {-3+y[1.]} is not a list of > numbers with dimension {1} at {x} = {2.}. > > This small program works perfectly for 4.1 and 4.2, but not for > 5. Does anybody knows why? > > If it is really a bug, how to inform the wolfram company? > > Best wishes, > Li-Xin Li I am also seeing what seems to me to be a bad bug in the 5.0 FindRoot function. As far as I can tell, the problem occurs when you attempt to execute FindRoot[ f [x] == 0, {x, x0, x1}] for a "sufficiently complicated" f[x]. The bug seems to be that the routine "sometimes" just passes a symbolic 'x' to f[x] instead of a numerical value. Whether or not you get this bug seems to depend upon what f[x] actually does. In my case, f[x] was a Module with a numerical integration embedded, which of course then failed because the integrand was not numeric. When I then inserted a Print[x] at the top of the f[x_] Module, I got an 'x' and not a number! This renders the FindRoot function useless, of course, unless someone sees a work-around. This problem was spotted by good code that executes fine in 4.1 but fails badly in 5.0. (I did have to change {x, {x0 , x1}} to {x, x0, x1}, as per the Help Browser. The Help Bowser doc changes definitely suggest that this this function has been modified. Any comments from others who have seen this, or see a work-around, or WRI people would be most appreciated. Regards, alan
- Follow-Ups:
- Re: a bug in mathematica 5?
- From: Jason Sidabras <sidabras.jason@nsgcorp.net>
- Re: a bug in mathematica 5?