Hello all, I am attempting to write a C Program that will estimate the results of a definite integral using the Trapezoidal Rule. My hang up is the sum portion of the rule of i=1 to n-1 f(xi)
the formula i have for the trapezoidal rule is:
integral from a to b f(x)dx approx: h/2(f(a) + f(b) + 2 SUM i=1 -> n-1 f(xi))
with an integral of: 1 to 5 x^2sin(x) dx assuming n = 150.
What I have that is NOT working is the following:
SUM = n/2[a1 + an] = 150/2[sin(1) + 1492sin(149)]
and when i put it all together i have:
h = (b-a)/n = 4/150 = 2/75
h/2 = 1/75
1/75[ sin(1) + 25sin(5) + 2 { 50/2[sin(1) + 1492sin(149)] } ]
using my Ti93 to solve the definite integral i get an approx answer of 2.7, but when i plug in the above equation i get an approx answer of 350. that is a significant error.
Some assistance would be greatly appreciated.
Thank you in advance.
the formula i have for the trapezoidal rule is:
integral from a to b f(x)dx approx: h/2(f(a) + f(b) + 2 SUM i=1 -> n-1 f(xi))
with an integral of: 1 to 5 x^2sin(x) dx assuming n = 150.
What I have that is NOT working is the following:
SUM = n/2[a1 + an] = 150/2[sin(1) + 1492sin(149)]
and when i put it all together i have:
h = (b-a)/n = 4/150 = 2/75
h/2 = 1/75
1/75[ sin(1) + 25sin(5) + 2 { 50/2[sin(1) + 1492sin(149)] } ]
using my Ti93 to solve the definite integral i get an approx answer of 2.7, but when i plug in the above equation i get an approx answer of 350. that is a significant error.
Some assistance would be greatly appreciated.
Thank you in advance.