MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: a bug in mathematica 5?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43266] Re: a bug in mathematica 5?
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Sat, 23 Aug 2003 08:08:45 -0400 (EDT)
  • Organization: University of Washington
  • References: <bh2714$hra$1@smc.vnet.net> <bht3t5$n4a$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Alan and others,

It seems to me that the simple solution to your problem is to prevent your
function from evaluating when given nonnumeric input. So, in Li-Xin Li's
case, simply change the definition for u to:

u[x_?NumericQ]:=((y[1] /. sol[x])[[1]])-3

However, I don't have version 5.0 to verify that this will solve your
problem.

Carl Woll
Physics Dept
U of Washington

"Alan" <infoNOSPAM at optioncity.net> wrote in message
news:bht3t5$n4a$1 at smc.vnet.net...
>
> "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
>



  • Prev by Date: Simplification of radicals
  • Next by Date: Re: New version, new bugs
  • Previous by thread: Re: a bug in mathematica 5?
  • Next by thread: Re: a bug in mathematica 5?