       Re: FindRoot & NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg64673] Re: [mg64650] FindRoot & NDSolve
• From: Pratik Desai <pdesai1 at umbc.edu>
• Date: Sun, 26 Feb 2006 05:07:55 -0500 (EST)
• References: <200602250753.CAA13936@smc.vnet.net> <44008AE9.6070708@umbc.edu>
• Sender: owner-wri-mathgroup at wolfram.com

```Pratik Desai wrote:

> Takashi Inoue wrote:
>
>> 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}, f, {x, -3,
>> 3} ][]) == 4,
>> {a, -10, 10}
>>           ]
>
> I think FindRoot requires a initial guess in 5.X and you need some
> kind of looping for your different values of a
>
>
> Here are two possible alternatives (that I could think of) using
> DSolve and NDSolve
>
> (*Using DSolve (more preferable perhaps because of the closed form
> nature)*)
>
> TableForm[{#,x/.FindRoot[(f/.DSolve[{D[f[x], {x,1}]== 2 x + #, f ==
> 0}, f,
> for f[x,a]"}}]
>
> (*Using NDSolve  )
>
> Clear[f,x,a]
> Table[Reap[NDSolve[{D[f[x], {x,1}]== 2 x + a, f == 0}, f, {x,-3,3},
> Method->{EventLocator,
> "Event"->f[x]-4,"EventAction":>Sow[{a,x}]}],{a,-10,10,1}]

There is an error in the above code for NDSolve, here is the correct one
Table[NDSolve[{D[f[x], {x,1}]== 2 x + a, f == 0}, f, {x,-3,3},
Method->{EventLocator,
"Event"->f[x]-4,"EventAction":>Print[{a,x}]}],{a,-10,10,1}];

>
>
> Hope this helps
>
> Pratik
>
>> Takashi Inoue,Dept. Phys. Sophia University
>
>
>
>

```

• Prev by Date: Re: 3D Graphics suggestions?
• Next by Date: Re: Re: Code to translate to negative base...
• Previous by thread: Re: FindRoot & NDSolve
• Next by thread: Re: FindRoot & NDSolve