Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7787 > unrolled thread

Re: NDSolve output without interpolating function

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-01-14 07:53 +0000
Last post2012-01-14 07:53 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: NDSolve output without interpolating function Bob Hanlon <hanlonr357@gmail.com> - 2012-01-14 07:53 +0000

#7787 — Re: NDSolve output without interpolating function

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-01-14 07:53 +0000
SubjectRe: NDSolve output without interpolating function
Message-ID<jerc9g$17f$1@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!

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web