MathGroup Archive 1999

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

Search the Archive

How to do Simpson's Rule Riemann Sums with Mathematica 3.0?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16913] How to do Simpson's Rule Riemann Sums with Mathematica 3.0?
  • From: "Vinod Nagubadi" <vinod at nagubadi.com>
  • Date: Tue, 6 Apr 1999 01:27:37 -0400
  • Organization: EarthLink Network, Inc.
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I figured out how to do Left, Right, and Midpoint Riemann Sums with the
equations below.  Does anyone know how to modify these to do Trapezoidal and
Simpson's Rule Riemann Sums?  Thanks a heap!

RiemannRight[ f_,a_,b_,n_]:=Module[ {S=0,h=(b-a)/n,x=a} ,
o[ x=x+h;S=S+h*f[x],{n}] ;N[S]]
RiemannLeft[ f_,a_,b_,n_]:=Module[ {S=0,h=(b-a)/n,x=a} ,
o[ S=S+h*f[x];x=x+h,{n}];N[S]]
RiemannMidpt[ f_,a_,b_,n_]:=Module[ {S=0,h=(b-a)/n,x=a} ,
o[ S=S+h*f[x+h/2];x=x+h,{n}];N[S]]

Now all I need are the Trapezoidal and Simpson's Rule.

Thanks in advance,

Vinod Nagubadi




  • Prev by Date: Re: question about entering vectors by the keyboard
  • Next by Date: Re: New position: MathLink Developer
  • Previous by thread: Re: ContourPlot: non-rectangular domains?
  • Next by thread: Scheduling algorithms