Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports

# Thread: Integral solution using Simpson's Rule

1. Member
Join Date
3rd June 2005
Posts
24

## Integral solution using Simpson's Rule

Integral solution using Simpson's Rule(numerical integration) in VBA. Using any integral formula, does anybody out there knows how to use VBA to get integral solution using simpson's rule?
Last edited by Isabella; June 9th, 2005 at 17:02. Reason: change title

Excel Video Tutorials / Excel Dashboards Reports

2. Super Moderator
Join Date
26th January 2003
Location
Derbyshire,UK
Posts
19,808

## Re: huh?

Please use a helpful title when posting questions. This thread's title is totally useless!!!! It cannot be used in Searches & will probably not attract too much attention.

3. Member
Join Date
3rd June 2005
Posts
24

## Re: Integral solution using Simpson's Rule

is that ok?

Excel Video Tutorials / Excel Dashboards Reports

4. Super Moderator
Join Date
26th January 2003
Location
Derbyshire,UK
Posts
19,808

## Re: Integral solution using Simpson's Rule

I think you might find you get more help now. Thanks

5. ## Re: Integral solution using Simpson's Rule

you can find all you want in Numerical Recipes

http://www.library.cornell.edu/nr/bookcpdf/c4-2.pdf

filo65

Excel Video Tutorials / Excel Dashboards Reports

6. Member
Join Date
3rd June 2005
Posts
24

## Re: Integral solution using Simpson's Rule

Thanks

Excel Video Tutorials / Excel Dashboards Reports

7. Member
Join Date
5th May 2005
Location
Hershey, PA
Posts
21

## Re: Integral solution using Simpson's Rule

It's not as stringent as simpson's rule, but here's a numerical integration UDF I wrote using the trapezoid rule. Perhaps it will be good enough for your situation.

VB:
```Function AUC(xRng As Range, yRng As Range) As Double
' Approximation of the definite integral using the Trapezoid rule
Dim xRows As Integer, yRows As Integer
Dim xRow As Integer, yRow As Integer
Dim LeftRule As Double, RightRule As Double, TrapRule As Double, MidRule As Double
xRows = xRng.Rows.Count
yRows = yRng.Rows.Count
RightRule = 0
LeftRule = 0
TrapRule = 0

For i = 2 To xRows
RightRule = RightRule + yRng.Cells(i, 1) * (xRng.Cells(i, 1) - xRng.Cells(i - 1, 1))
LeftRule = LeftRule + yRng.Cells(i - 1, 1) * (xRng.Cells(i, 1) - xRng.Cells(i - 1, 1))
TrapRule = (LeftRule + RightRule) / 2
Next i
AUC = TrapRule
End Function

```

Excel Video Tutorials / Excel Dashboards Reports

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
porno