Re: FindRoot & NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg64670] Re: [mg64650] FindRoot & NDSolve
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sun, 26 Feb 2006 05:07:52 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```You can use Hold to keep NDSolve from trying to evaluate too soon.

FindRoot[Hold[(f/.NDSolve[{
f'[x]-2 x-a==0,f[0]==0},f,{x,-3,3}][[1]])[2]==4],{a,-10,10}]

{a -> -7.3171562090692666*^-9}

However, the differential equation can be solved exactly

FindRoot[(f/.DSolve[{f'[x]-2 x-a==0,f[0]==0},f,x][[1]])[2]==4,{a,-10}]

{a -> 0.}

And so can the resulting equation

Solve[(f/.DSolve[{f'[x]-2 x-a==0,f[0]==0},f,x][[1]])[2]==4,a][[1]]

{a -> 0}

Bob Hanlon

>
> From: Takashi Inoue <takash-i at sophia.ac.jp>
To: mathgroup at smc.vnet.net
> Subject: [mg64670] [mg64650] FindRoot & NDSolve
>
> Hi all,
>
> This is my first post to here.
> I have a problem and want your help.
>
> Mathematica 4 did the following calculation with no pleblem,
> while Mathematica 5(.2)  cannot do it.
>
> FindRoot[
>  (f /.NDSolve[ {D[f[x], {x,1}] - 2 x - a == 0, f[0] == 0}, f, {x, -3, 3}
> ][[1]])[2] == 4,
>  {a, -10, 10}
>               ]
>
> Does anyone know solution or altanative way to do it?
>
> Takashi Inoue,
> Dept. Phys. Sophia University
>
>

```

• Prev by Date: Re: 3D Graphics suggestions?
• Next by Date: Re: FindRoot & NDSolve
• Previous by thread: Re: FindRoot & NDSolve
• Next by thread: autogenerated packages carriage returns and line feeds