Write a generic VBA Sub procedure to compute the value of th

Write a generic VBA Sub procedure to compute the value of the following Integral (I) using the Trapezoidal Rule.

dac

Solution

// Trapazoidal rule calculates area under the curve
// n is number of interval
Function Integration(a As Integer, b as Integer, n As Integer) As Double

Dim sum as Double
sum = (F(a) + F(b))/2
For i = 1 To n - 1
sum = sum + F(a + ((b-a)/n)*i)
Next i

Integration = sum * (b-a)/n

End Function

Write a generic VBA Sub procedure to compute the value of the following Integral (I) using the Trapezoidal Rule. dac Solution// Trapazoidal rule calculates area

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site