Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4650 > unrolled thread
| Started by | Oliver Ruebenkoenig <ruebenko@wolfram.com> |
|---|---|
| First post | 2011-08-29 11:44 +0000 |
| Last post | 2011-08-31 10:11 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: NDSolve solution does not fulfill boundary condition Oliver Ruebenkoenig <ruebenko@wolfram.com> - 2011-08-29 11:44 +0000
Re: NDSolve solution does not fulfill boundary condition Alex <axel.kowald@gmail.com> - 2011-08-31 10:11 +0000
| From | Oliver Ruebenkoenig <ruebenko@wolfram.com> |
|---|---|
| Date | 2011-08-29 11:44 +0000 |
| Subject | Re: NDSolve solution does not fulfill boundary condition |
| Message-ID | <j3fu25$he6$1@smc.vnet.net> |
On Mon, 29 Aug 2011, Alex wrote:
> Hello everybody,
>
> I use Mathematica 7 and try to solve and plot a 2nd order ODE like this:
>
> sol = NDSolve[{0 == 4800*O2''[x] + 1500*Exp[-(100*x)^2] - 2000*O2[x],
> O2'[-0.5] == 0, O2'[0.5] == 0}, O2, {x, -1, 1}]
> Plot[O2[x] /. sol, {x, -1, 1}, PlotRange -> All]
>
> The solution looks ok, i.e. the slope of the solution is 0 at 0.5 and
> -0.5, as required by the boundary conditions. But if I slightly change
> the parameter values from 1500 to 1000 like this:
>
> sol = NDSolve[{0 == 4800*O2''[x] + 1000*Exp[-(100*x)^2] - 2000*O2[x],
> O2'[-0.5] == 0, O2'[0.5] == 0}, O2, {x, -1, 1}]
>
> I get a solution with slope=0 at -0.5, but with a positive slope at
> 0.5 !!??
>
> How can this be ? What am I doing wrong ?
>
> Many thanks,
>
> axel
>
>
Alex, my guess is that NDSolve just misses that point at O2[1/2] since it
is not an end point. You can use
sol = NDSolve[{0 == 4800*O2''[x] + 1000*Exp[-(100*x)^2] - 2000*O2[x]
, O2'[1/2] == 0, O2'[-1/2] == 0}, O2, {x, -1, 1},
MaxStepSize -> 0.1]
Plot[O2[x] /. sol, {x, -1, 1}, PlotRange -> All]
But for this case DSolve is better:
as = O2 /.
DSolve[{0 == 4800*O2''[x] + a*Exp[-(100*x)^2] - 2000*O2[x],
O2'[0.5] == 0, O2'[-0.5] == 0}, {O2}, x];
f1[x_] := Evaluate[(as[[1]][x] /. a -> 1000)]
f2[x_] := Evaluate[O2[x] /. sol]
Plot[f1[x] - f2[x], {x, -1, 1}, PlotRange -> All]
Hope this helps,
Oliver
[toc] | [next] | [standalone]
| From | Alex <axel.kowald@gmail.com> |
|---|---|
| Date | 2011-08-31 10:11 +0000 |
| Message-ID | <j3l1d6$bv5$1@smc.vnet.net> |
| In reply to | #4650 |
Hello Oliver, many thanks, both suggestions worked :-) I didn't realize that the ODE can be solved analytically. Of course, I will now use DSolve[] axel
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web