Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7787
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: NDSolve output without interpolating function |
| Date | 2012-01-14 07:53 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jerc9g$17f$1@smc.vnet.net> (permalink) |
| References | <201201130951.EAA16470@smc.vnet.net> |
You could generate a Table of points using the interpolating function;
however, it would be difficult to sample the function at the best
values. If you let Mathematica Plot the function then you can leverage
its sampling algorithm.
Clear[nDSolve]
nDSolve[eqn_, depVar_Symbol, iter_List, opts_: {}] :=
Module[{sol, plt, pts},
sol = depVar /. NDSolve[eqn, depVar, iter,
FilterRules[opts, Options[NDSolve]]][[1]];
plt = Plot[sol[iter[[1]]], iter,
Evaluate[FilterRules[opts, Options[Plot]]]];
pts = Cases[plt, Line[pts_] :> pts, Infinity][[1]];
{sol, plt, pts}]
sol = nDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1},
y, {x, 0, 30}, PlotRange -> All];
The result includes the interpolating function
Plot[sol[[1]][x], {x, 0, 30}, PlotRange -> All]
the plot used to capture the points
Show[sol[[2]]]
and the list of points
ListLinePlot[sol[[3]], PlotRange -> All]
Bob Hanlon
On Fri, Jan 13, 2012 at 4:51 AM, william cuervo <wfcuervo@gmail.com> wrote:
> Hi!
>
> Is there any way that NDSolve presents the output as a set of data instead
> of as an interpolating function?
>
>
> Thanks!
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: NDSolve output without interpolating function Bob Hanlon <hanlonr357@gmail.com> - 2012-01-14 07:53 +0000
csiph-web