Re: How to get data from solvin' numerically
- To: mathgroup at smc.vnet.net
- Subject: [mg104156] Re: [mg104129] How to get data from solvin' numerically
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 21 Oct 2009 06:30:49 -0400 (EDT)
- Reply-to: hanlonr at cox.net
s = y /. NDSolve[
{y'[x] == y[x] Cos[x + y[x]], y[0] == 1},
y, {x, 0, 30}][[1]];
The integral of the interpolation function is
int[x_?NumericQ /; 0 <= x <= 30] :=
Integrate[s[t], {t, 0, x}]
Plotting the function and its integral
Show[{p1 = Plot[s[x], {x, 0, 30},
PlotRange -> All],
p2 = Plot[int[x], {x, 0, 30}]},
Frame -> True, Axes -> False]
The plots were done separately to facilitate extraction of the points. Extracting the points from the plots
pts1 = Cases[p1, {_?NumericQ, _?NumericQ}, {6}];
pts2 = Cases[p2, {_?NumericQ, _?NumericQ}, {6}];
If you want to see the points displayed, remove the semi-colons that are suppressing their display. However, there are lots of points:
Length /@ {pts1, pts2}
{1281,634}
Showing that the points represent the original curves
ListLinePlot[{pts1, pts2}, PlotRange -> All, Frame -> True, Axes -> False]
Bob Hanlon
=D0=B8=D0=BD=D0=BE=D0=B2" <shalm89 at gmail.com> wrote:
=============
Bob, thank you for your answer.
Should all the values(points of numerical solution of differential equation)
appear after the command ListLinePlot?
I can't see values of this points.
Do you know, how can I integrate this interpolated function?
Thank you again.
Best regards, Mikhail Shalaginov
2009/10/20 Bob Hanlon <hanlonr at cox.net>
>
> s = y /. NDSolve[
> {y'[x] == y[x] Cos[x + y[x]], y[0] == 1},
> y, {x, 0, 30}][[1]];
>
> p = Plot[s[x], {x, 0, 30}, PlotRange -> All,
> Frame -> True, Axes -> False]
>
> Extracting the points from the plot
>
> pts = Cases[p, {_?NumericQ, _?NumericQ}, {6}];
>
> Length[pts]
>
> 1281
>
> ListLinePlot[pts, PlotRange -> All,
> Frame -> True, Axes -> False]
>
>
> Bob Hanlon
>
> ---- "=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB =D0=A8=D0=B0=D0=BB=D0=B0=D0=B3=
=D0=B8=D0=BD=D0=BE=D0=B2" <shalm89 at gmail.com> wrote:
>
> =============
> Hi,
> Mathematica solves numerically differential equation and makes
> interpolation. I can plot this interpolating function. Can I save all
> the points in a file or somehow get this data?
> Best regards, Mikhail Shalaginov.
>
>
--
Bob Hanlon