[Date Index]
[Thread Index]
[Author Index]
Re: FindRoot in Version 5
*To*: mathgroup at smc.vnet.net
*Subject*: [mg46321] Re: FindRoot in Version 5
*From*: drbob at bigfoot.com (Bobby R. Treat)
*Date*: Sat, 14 Feb 2004 04:37:56 -0500 (EST)
*References*: <c0fh4j$9ls$1@smc.vnet.net> <c0hvrv$oq2$1@smc.vnet.net> <c0k443$8li$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
I'm surprised the == sign worked here, in fact; I got it from your
post, and it worked, so I didn't even notice it. But I'm using 5.0.1.
I suppose that's the difference.
Bobby
bghiggins at ucdavis.edu (Brian Higgins) wrote in message news:<c0k443$8li$1 at smc.vnet.net>...
> Bobby, Your version of the code does not converge on my mac OSX using
> version 5.0 for Mac OS X (June 11, 2003). What I have found is that
> removing the equality sign from the first argument of FindRoot is
> required (after one has forced the function passed to FindRoot to be
> numerical.) Thus the following works on my system
>
> system[a_] := {Derivative[1][y1][x] ==
> y2[x], Derivative[1][y2][x] == -Sin[y2[ x]] + Cos[5*x], y1[-1] ==
> 0,
> y2[-1] == a};
> myODEsoln[a_] := NDSolve[system[a], {y1[x], y2[x]}, {x, -1, 1}]
> yend[(a_)?NumericQ] := First[y1[x] /. myODEsoln[a] /. x -> 1]
> bc = FindRoot[yend[a], {a, -2, 2}];
> Plot[Evaluate[y1[x] /. myODEsoln[a /. bc]], {x, -1, 1},
> AxesLabel -> {"x", "y1(x)"}];
>
> I have tested this remedy out on other code that I have and it fixes
> the problem (both on windows and Mac system with Version 5)
>
> The original code I posted got warped during transcription from the
> notebook; the "?" should have been an omega. And yes it would not
> have worked on any of my versions of Mathematica. I posted a
> correction. Sorry for the confusion
> Thanks much
>
> Brian
>
> drbob at bigfoot.com (Bobby R. Treat) wrote in message news:<c0hvrv$oq2$1 at smc.vnet.net>...
> > This works in version 5:
> >
> > system[a_] := {Derivative[1][y1][x] ==
> > y2[x], Derivative[1][y2][x] ==
> > -Sin[y2[x]] + Cos[5*x], y1[-1] == 0,
> > y2[-1] == a};
> > myODEsoln[a_] := NDSolve[system[a],
> > {y1[x], y2[x]}, {x, -1, 1}]
> > yend[(a_)?NumericQ] :=
> > y1[x] /. myODEsoln[a] /. x -> 1
> > bc = FindRoot[First[yend[a]] == 0,
> > {a, -2, 2}];
> > Plot[Evaluate[y1[x] /. myODEsoln[
> > a /. bc]], {x, -1, 1},
> > AxesLabel -> {"x", "y1(x)"}];
> >
> > It's hard to imagine how your code could have worked in ANY version,
> > but if you say so....
> >
> > Bobby
> >
> > bghiggins at ucdavis.edu (Brian Higgins) wrote in message news:<c0fh4j$9ls$1 at smc.vnet.net>...
> > > Hi,
> > >
> > > In version 4 I used the following code to solve nonlinear BVP using
> > > NDSolve
> > >
> > > system[?_] := {y1'[x] == y2[
> > > x], y2'[x] == -Sin[y2[x]] + Cos[5x], y1[-1] == 0, y2[-1] == ?};
> > > myODEsoln[?_] := NDSolve[system[?], {y1[x], y2[x]}, {x, -1, 1}]
> > > yend[?_] := (y1[x] /. myODEsoln[?]) /. x -> 1
> > > bc = FindRoot[First[yend[?]] == 0, {?, -2, 2}];
> > > Plot[Evaluate[y1[x] /. myODEsoln[? /. bc]], {
> > > x, -1, 1}, AxesLabel -> {"x", "y1(x)"}];
> > >
> > > In Version 5 is does not work. I have read on this group that FindRoot
> > > was modified so that it now requires that in the above code I replace
> > > yend[Q_] with yend[Q_?NumericQ]. But now the problem is that FindRoot
> > > fails to converge.
> > >
> > > So my question: Does anyone know what other modifications have been
> > > made to FindRoot so that I can get this code and many others like it
> > > to work again?
> > >
> > > Thanks much
> > >
> > > Brian
Prev by Date:
**Re: A zillion times slower in version 5**
Next by Date:
**Can Mathematica Ver 5 Import ESRI *.shp, *.shx and DBase *.dbf files??**
Previous by thread:
**Re: FindRoot in Version 5**
Next by thread:
**Re: FindRoot in Version 5**
| |