MathGroup Archive 2001

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

Search the Archive

Re: "Incremental Integration"?

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

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]]]

Cheers,
Brian

aes <siegman at stanford.edu> wrote in message news:<9ua3qg$194$1 at smc.vnet.net>...
> 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"?