[Date Index]
[Thread Index]
[Author Index]
Re: Boundary Value Problems
*To*: mathgroup at smc.vnet.net
*Subject*: [mg15018] Re: [mg14997] Boundary Value Problems
*From*: Jurgen Tischer <jtischer at col2.telecom.com.co>
*Date*: Sat, 5 Dec 1998 01:30:21 -0500
*Organization*: Universidad del Valle
*References*: <199812020859.DAA23467@smc.vnet.net.>
*Sender*: owner-wri-mathgroup at wolfram.com
AC,
I have no package but teach my students how to use Mathematica to solve
boundary problems with shooting. And I think Mathematica is able to
treat quite nasty ODE's. I add two examples to illustrate the method.
1. Example, easy, to show the method
Mathematica's NDSolve is not able to solve the following (generalized)
boundary problem automatically.
NDSolve[{y'''[t] - t y'[t] + 2 y[t] == -10 + t, y[-1] == 3,
y'[2] == 4, y[4] == 3}, y, {t, -1, 4}]
We define
f1[a_, b_] := NDSolve[{y'''[t] - t y'[t] + 2 y[t] == -10 + t, y[-1] ==
3,
y'[-1] == a, y''[-1] == b}, y, {t, -1, 4}]
f2[a_,b_]:=With[{f=First[y/.f1[a,b]]},{f'[2],f[4]}]
and solve with FindRoot.
sol=FindRoot[f2[a,b]=={4,3},{a,{0,1}},{b,{0,1}}]
Plot[Evaluate[y[t]/.f1[a/.sol,b/.sol]],{t,-1,4}]
2. Example, from the book of Stoer and Bulirsch, which they use to
illustrate that simple shooting is NOT sufficient to solve nasty
problems and use it as motivation to introduce multiple shooting (and I
demonstrate that Mathematica does it with simple shooting and ease).
The problem: y''[t]==5 Sinh[5 y[t]], y[0]==0, y[1]==1
There is an analytic solution, but Mathematica doesn't find it:
In[1]:= DSolve[y''[t] == 5*Sinh[5*y[t]], y, t]
Solve::"ifun":
"Inverse functions are being used by Solve, so some solutions may not
be found."
Out[1]= {{y -> (-Infinity & )}, {y -> (Infinity & )}}
We proceed as before,
f3[a_]:=NDSolve[{y''[t]==5 Sinh[5 y[t]],y[0]==0,y'[0]==a},y,{t,0,1}]
but it turns out that the solution sometimes doesn't reach the right
boundary.
In[2]:= f3[1]
NDSolve::"ndsz":
"At t == 0.43129882432337574, step size is effectively zero;
singularity suspected."
Out[2]= {{y->InterpolatingFunction[{{0.,0.431299}},"<>"]}}
We turn off the message
Off[NDSolve::ndsz]
and cheat a bit in the definition of the second function
f4[a_]:=With[{f=f3[a][[1,1,2]]},f[f[[1,1,2]]]]
If f3[a] doesn't reach the right extreme, we use instead the last value
calculated. Now we proceed again as before.
sol=FindRoot[f4[a]==1,{a,{0,1}}]
Plot[Evaluate[y[t]/.f3[a/.sol]],{t,0,1}]
I think this shows how to solve a large class of boundary value
problems.
Jurgen
Wretch wrote:
>
> Have any useful packages been written to solve boundary value
> (eigenvalue) problems? For instance, something that discretizes nasty
> ODE and solves the resulting matrix equation for the eigenvalues? I
> checked the FAQ and the MathSource link at the Mathematica webpage, but
> I found nothing particularly useful.
>
> Thanks,
>
> AC
Prev by Date:
**Re: Contour Integration**
Next by Date:
**Re: How to create a mask with a hole in it?**
Previous by thread:
**Boundary Value Problems**
Next by thread:
**Contour Integration**
| |