[Date Index]
[Thread Index]
[Author Index]
NDSolve Problem
*To*: mathgroup at smc.vnet.net
*Subject*: [mg91692] NDSolve Problem
*From*: pratip <pratip.official at gmail.com>
*Date*: Fri, 5 Sep 2008 07:14:50 -0400 (EDT)
Lets take this system of ODE and solve with DSolve
exsol = DSolve[{x1'[t] == x2[t],
x2'[t] == c^2 x1[t] - (c^2 + p^2) Sin[p t], x1[0] == 0,
x2[0] == Pi}, {x1[t], x2[t]}, t] // FullSimplify
solution is as follows
{{x1[t] -> Sin[p t] + ((-p + \[Pi]) Sinh[c t])/c,
x2[t] -> p Cos[p t] + (-p + \[Pi]) Cosh[c t]}}
Here is the values of the parameters
dp = {c -> 100, p -> 2}
Now solve with NDSolve
sol = NDSolve[{x1'[t] == x2[t],
x2'[t] == c^2 x1[t] - (c^2 + p^2) Sin[p t], x1[0] == 0,
x2[0] == Pi} /. dp, {x1, x2}, {t, 0, 2}]
Lets Plot the residual error
Res = {-x1'[t] + x2[t], -x2'[t] + c^2 x1[t] - (c^2 + p^2) Sin[p t]};
Plot[Evaluate[Res /. sol /. dp], {t, 0, 2}]
One can see the exponential increase in error. Please tell me if it is possible to manage this error for any parameter values. I want to know how I can use NDSolve to simulate such ODE with very little residual error just like any other normal system of ODE. Should I choose some special method options?
Another very funny thing
der = D[exsol, t];
Res /. exsol /. der /. dp // Flatten // FullSimplify
gives {0,0}. But lets take the residual with out simplifying.
res = Res /. exsol /. der /. dp // Flatten;
Plot[Evaluate[res], {t, 0, 1.2}, PlotStyle -> Thick]
The Plot shows how badly exponential error shows up in the boundary. Is it a problem with Plot command? why it can not understand without simplifying that "res={0,0}". I hope you guys have an answer.
Prev by Date:
**Re: Thinking Mathematica: Any suggestions?**
Next by Date:
**matrix matching**
Previous by thread:
**Re: question about Solve**
Next by thread:
**Re: NDSolve Problem**
| |