MathGroup Archive 2001

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

Search the Archive

Re: "Incremental Integration"?

  • To: mathgroup at
  • Subject: [mg31791] Re: "Incremental Integration"?
  • From: bghiggins at (Brian Higgins)
  • Date: Sun, 2 Dec 2001 04:25:10 -0500 (EST)
  • References: <9ua3qg$194$>
  • Sender: owner-wri-mathgroup at

Here is one way if you are willing to use the Map function in your code:

incrementalIntegrate[f_, xStart_, xFinal_, deltaX_] := 
  Map[{#[[1]], #[[2]], NIntegrate[f, {x, #[[1]], #[[2]]}]} &, 
    Map[{xStart, #} &, Range[xStart, xFinal, deltaX]]]

Here is a table of values for Sin[x]: 

incrementalIntegrate[Sin[x], 0, 3\[Pi], .3] // TableForm

Here is a plot of those values

ListPlot[Map[Drop[#, 1] &, incrementalIntegrate[Sin[x], 0, 3\[Pi], .3]]]


aes <siegman at> wrote in message news:<9ua3qg$194$1 at>...
> Given a rather messy function  f[x] , I want to make a Table of its integral 
> from  x0 up to a set of equally spaced points xn = x0 + n*dx  with maximum value 
> xFinal -- in other words
>    g[x_] := NIntegrate[f[xi], {xi, x0, x}]
>    Table[ {x, g[x]}, {x, x0, xFinal, dx}]
> Is Mathematica smart enough to calculate each successive value using the 
> previous value plus integration just over the increment in x to the next value?
> If not, what would be a clean and readable and also reasonably efficient way to 
> code this?
> [Note:  For me anyway, there's some emphasis on the "clean and readable" part -- 
> avoiding esoteric Mathematica syntax, not taking terseness as the ultimate goal.]
> Email cc to poster appreciated.

  • Prev by Date: Re: Re: EPS Export, Wrong characters
  • Next by Date: Re: Finding determinants of nxn matrices
  • Previous by thread: "Incremental Integration"?
  • Next by thread: Re: "Incremental Integration"?