1. ## Excel/VBA/Simpson's Rule???

Hello all,

I'm trying to figure out a code in Excel's VBA (visual basic, excel's macro programming thing) that will take input from an excel spreadsheet and perform the Simpson's Rule on a quadratic function. Ex: Take a,b,c as input from the spreadsheet (for the quadratic ax^2+bx+c=0) It also has to take the upper limit and lower limits of the integral (A=0, B=5) and the number of integers to use (n=100, etc) from the spreadsheet and give the answer as output on the spreadsheet.

I know this probably sounds confusing, but I could really really use some help with this, I figured out the traprule already, just have no clue about the Simpson's Rule. Thanks!

2. Originally Posted by UDaytonFlyer
Hello all,

I'm trying to figure out a code in Excel's VBA (visual basic, excel's macro programming thing) that will take input from an excel spreadsheet and perform the Simpson's Rule on a quadratic function. Ex: Take a,b,c as input from the spreadsheet (for the quadratic ax^2+bx+c=0) It also has to take the upper limit and lower limits of the integral (A=0, B=5) and the number of integers to use (n=100, etc) from the spreadsheet and give the answer as output on the spreadsheet.

I know this probably sounds confusing, but I could really really use some help with this, I figured out the traprule already, just have no clue about the Simpson's Rule. Thanks!
In Excel, custom name a few cells. aval, bval, cval, inthigh, intlow, nval. This will stand for a, b, c, integral high value, integral low value, and integer n value. Now, in VB, do the following:

Dim a, b, c, ihigh, ilow, simp1, fa, fb, simp2, adb, simpson, As Double
Dim n as Integer

' Validate user input

' Inputs
a = Range("aval").Value
b = Range("bval").Value
c = Range("cval").Value
ihigh = Range("inthigh").Value
ilow = Range("intlow").Value
n = Range("nval").Value

If Len(a) = 0 Or Len(b) = 0 Or Len(c) = 0 Or Len(ihigh) = 0 Or Len(ilow) = 0 Or Len(n) = 0 Then
' Alert user that entries have not been filled out
MsgBox "You need to enter input values before continuing.", vbExclamation, "Warning Message"
Exit Sub
End If

simp1 = (b-a)/6
fa = (a * aval^2) + (b * aval) + c
simp2 = 4 * ((a * adb^2) + (b * adb) + c)
fb = (a * bval^2) + (b * bval) + c

' Calculate Simpson value
simpson = simp1*(fa + simp2 + fb)

I got that formula from here:

http://en.wikipedia.org/wiki/Simpson's_Rule

You'll need to output the simpson value somewhere on the spreadsheet or a message box. Let me know if you need help with that. I put this code together quickly this morning. i'm not sure how much VB/Excel knowledge you have, so if you do have questions, by all means, ask.

I assume you are doing this in VBA to hide it from others, but it's very easy to do in Excel. I put in a warning message to validate user input, and made it an Exclamation warning to catch the user's eye if they make a mistake on entry points.

3. ## trap rule

Hey Flyer I am working on a VB code for the trap rule. You said you already figured it out. Think you could help me out?

4. ## I am working in php I have problem with numerical methods

Hello,
I am a MCA student.
I am developing a site for maths in which I am implementing the numerical methods I have code for trapezoidal,simpsons1/3rd,simpsons3/8th rule in c but I want to convert it into PHP.Can you give me a solution .
Actually I have written this code in PHP but its not working.I am not getting the proper solution will you please help me.
Its urgent.
Thanks and Regards,
Bye.

5. For the .php conversion, do everything I did for the VB, adding dollar signs in front of the variables.

Then, you would need to setup entry boxes for any user entry fields on my Excel file which are sent down to php and use the GET method. Are you familiar with that?

,

,

,

,

# vba simpson's rule

Click on a term to search for related topics.