Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Version problem with FindRoot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97190] Re: Version problem with FindRoot
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 7 Mar 2009 02:41:30 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <goqug8$ng0$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

system[x_?NumericQ] = {2 w'[n] + f[n]*w[n] == 0, w[n] == v'[n],
   v[n] == f'[n], w[0] == x, v[0] == 0, f[0] == 0};

gun[x_?NumericQ] := (soln =
      NDSolve[system[x], {w, v, f}, {n, 0, 10}])[[1, 2, 2]][10.]


FindRoot[gun[x] == 1, {x, 1, .5}]

work fine.

Regards
   Jens

Dr. Robert Kragler wrote:
> Hi,
>
> according to a short note of Alan Hayes, TJM Vol.3, issue 3 (1993 ! )
> there is a 3-liner given for solving boundary problems of ODEs with the=

> help of the so-called shooting method. The subsequent program
>
>     system[x_]={2 w'[n]+f[n]* w[n]==0,w[n]==v'[n],v[n]==f=
'[n],w[0]==x
> ,v[0]==0,f[0]==0 }
>
>   gun:=(soln=NDSolve[system[#],{w,v,f},{n,0,10}])[[1,2,2]][10.]&
>
>   FindRoot[gun[x]==1,{x,1,.5}]  (* should give x->0.332058 *)
>
> works with earlier Mathematica versions 3.0, 4.2 but NOT for 5.2 (which=

> I am currently still using in order to finish a manuscript before I wil=
l
> adapt this to version 7.0). In Mathematica version 6.0 and 7.0 FindRoot=

> will work again if the following (version 6 ) system option is used :
>
>   SetSystemOptions["EvaluateNumericalFunctionArgument"->False]
>
> There is no problem to plot the function gun[x]with Plot[gun[x],{x,0,1}=
]
> in Mathematica.
> However, in Mathematica version 5.2 FindRoot gives rise to the followin=
g
> (error) message :
>
> NDSolve::"ndinnt": "Initial condition x is not a number or a rectangula=
r
> array of numbers."
>
> FindRoot::nlnum : The function value {-1.+v?[n][10.`] is not a list of
> numbers with
> dimensions {1} at {x} = {1.`}.}
>
> Does anybody have an idea what to do in the case of version 5.2 ? Thank=
s
> for any suggestion.
>
> Robert Kragler
>
> email:   kragler at hs-weingarten.de
>
>
>


  • Prev by Date: Re: list/sequence problem: a 'keep' list to a list of
  • Next by Date: Re: "Do What I Mean" - a suggestion for improving
  • Previous by thread: Re: Version problem with FindRoot
  • Next by thread: Re: Version problem with FindRoot