Re: FindRoot/NDSolve problem in VS5

*To*: mathgroup at smc.vnet.net*Subject*: [mg54851] Re: FindRoot/NDSolve problem in VS5*From*: bghiggins at ucdavis.edu*Date*: Fri, 4 Mar 2005 05:07:47 -0500 (EST)*References*: <d060tf$kpt$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Tony, Due to changes in FindRoot in version 5 you need to add the following line to your code BC[s_?NumericQ] := ((y[x] /. eqsol[s][[1]] ) /. x -> 1) Then the algorithm for the shooting method is deq = y''[x] - x^2 y[x] == x + x^3; eqsol[s_] := NDSolve[{deq, y[-1] == 0, y'[-1] == s}, y[x], {x, -1, 1}] y[x] /. eqsol[1][[1]] /. x -> 1; BC[s_?NumericQ] := ((y[x] /. eqsol[s][[1]] ) /. x -> 1) ss = FindRoot[BC[s] == 0, {s, 0, 10}] ysol[x_] = y[x] /. eqsol[s /. ss][[1]] Out[5]= {s -> 0.5197957482122294} Out[6]= InterpolatingFunction[][x] Cheers, Brian