MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: How to get data from solvin'

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104816] Re: [mg104143] Re: [mg104128] How to get data from solvin'
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 10 Nov 2009 06:03:56 -0500 (EST)
  • References: <200910200852.EAA06192@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

For instance:

Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]

Clear[y]
s = y /. First@
     NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}];

pts1 = {#, s@#} & /@ First@InterpolatingFunctionCoordinates@s;
ListPlot@pts

You could also do it in reverse, so to speak, without the extender package:

Clear[y]
s = y /. First@
     NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}];
p = Plot[s@x, {x, 0, 30}, PlotRange -> All];
pts2 = First@Cases[p, Line[points_] :> points, Infinity];

That's a larger set of points, however:

Length /@ {pts1, pts2}

{339, 1281}

Here's the maximum error at the original points:

s'[#] - s[#] Cos[# + s[#]] & /@ pts1[[All, 1]] // Abs // Max

1.61028*10^-8

and here's an error computation for the plotted function:

s2 = Interpolation@pts2;
s2'[#] - s2[#] Cos[# + s2[#]] & /@ pts2[[All, 1]] // Abs // Max

0.000330339

Bobby

On Wed, 21 Oct 2009 05:28:23 -0500, Scot Martin <smartin at seas.harvard.edu>  
wrote:

> Yes, there are some features in an extender package. In help file, use
> "tutorial/NDSolvePackages" and then start reading there.
>
>
> -----Original Message-----
> From: =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 =
> [mailto:shalm89 at gmail.com]
> Sent: Tuesday, October 20, 2009 04:53
> To: mathgroup at smc.vnet.net
> Subject: [mg104143] [mg104128] How to get data from solvin' numerically =
> differential equation?
>
> 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.
>
>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: fitting
  • Next by Date: Re: incompatibilities
  • Previous by thread: Re: Re: Text cell formating blues. LineBreakWithin,
  • Next by thread: Re: Ten chess-players...