       Re: solving DE numerically....

• To: mathgroup at smc.vnet.net
• Subject: [mg126702] Re: solving DE numerically....
• From: danl at wolfram.com
• Date: Fri, 1 Jun 2012 05:16:38 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <jq74dd\$qj1\$1@smc.vnet.net>

```On Thursday, May 31, 2012 1:51:25 AM UTC-5, raj kumar wrote:
> hi all,
> greetings from sunny malaysia!
> this pertains to solving a  DE numerically at 5 differnt points.Should be straigth forward. But i get different results when i try to insert one parameter "by hand".have i overlooked something?
>
> any feed-back will be most appreciated
>
> Please consider the following:
>
> In:= pw3 = Piecewise[{{V0, x < a}, {V0, x == a}}, 0];
> k = Sqrt[10 - pw3];
> V0 = -1;
> a = 2;
> Table[{x, k}, {x, 1, 5}]
> (*Plot[Piecewise[{{V0, x<a}, {V0,x==a}},0],{x,0,5}]*)
>
>
> Out= {{1, Sqrt}, {2, Sqrt}, {3, Sqrt}, {4, Sqrt[
>   10]}, {5, Sqrt}}
>
> Solve the following DE numerically for y1[
>   1.0], y1[2.0], y1, y1, y1
>
> In:=
> s33 = NDSolve[{(y1^\[Prime]\[Prime])[x] + Sqrt[k] y1[x] == 0,
>     y1[0.1] == 0, Derivative[y1][0.1] == 1/10^6}, y1, {x, 1, 10}];
>
>
> We obtain
>
> In:= {y1[1.0], y1[2.0], y1, y1, y1} /. s33
>
> Out= {{6.9408*10^-7,
>   4.08303*10^-7, -5.09458*10^-7, -6.64851*10^-7, 1.70684*10^-7}}
>
> now check the output above for the values  x =
>  1 to x = 5. For x = 1, 2,
> we insert k =
>  Sqrt by hand in the same DE above and work out the values for \
> the same points again.  We get
>
> In:=
> s11 = NDSolve[{(y11^\[Prime]\[Prime])[x] + Sqrt[ 11] y11[x] == 0,
>     y11[0.1] == 0, Derivative[y11][0.1] == 1/10^6},
>    y11, {x, 1, 10}];
>
> In:= {y11[1.0], y11[2.0]} /. s11
>
> Out= {{5.47931*10^-7, -1.68202*10^-7}}
>
> Out= {{5.47931*10^-7, -1.68202*10^-7}}
>
> For x = 3, 4, 5, k = Sqrt. We get
>
> In:=
> s11 := NDSolve[{(y11^\[Prime]\[Prime])[x] + Sqrt y11[x] == 0,
>     y11[0.1] == 0, Derivative[y11][0.1] == 1/10^6},
>    y11, {x, 1, 10}];
>
>
>
> In:= {y11, y11, y11} /. s11
>
> Out= {{-5.30318*10^-7, 3.34051*10^-7, 4.16315*10^-7}}
>
> Qn : Should  the values for  y11[1-5] be any different from that calculated earlier ie  y1[1-5]?

As you note, k is sqrt(11) for x<2. You are using sqrt(k) in your DE, not k, so you'd want (11)^(1/4) rather than sqrt(11) in the second DE.

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: vector ordering problem
• Next by Date: Re: solving DE numerically....
• Previous by thread: Re: Flattening a hypermatrix into an ordinary matrix
• Next by thread: Re: solving DE numerically....