bn9

bn9

  • NA
  • 24
  • 0

Trapezoidal and Rectangular Integration

Mar 2 2004 2:11 AM
im working on a program to integrate a function using rectangluar and trapezoidal integration. this is what i have little bit of so far, or that i understand to calculate the trapezoidal portion of an equation. Console.WriteLine(); double lower =0; double upper = 10; DoubleFunction function = new DoubleFunction( Example.Foo ); double integral = TrapezoidalRule.Integrate( function, lower, upper ); Console.WriteLine( "Integral from " + lower + " to " + upper + " is " + integral ); Console.ReadLine(); internal static double Foo( double d ) { return Math.Sin( d ) + ( d * d ); } the equation to INTEGRATE IS HERE: This program integrates f(x) = x^4 - 2x^3 -12x^2 + 3x + 40 over the interval 0 to 10 using rectangular and trapezoidal integration. With a sample width of 0.1 THE OUTPUT LOOKS LIKE THIS: The true value of the integral is xx.xxxxxx <---- the true value is just a constant that i have already calculated------> Using rectangular integration the integral value is yy.yyyyyy Using trapezoidal integration the integral value is zz.zzzzzzz CAN ANYONE HELP????

Answers (3)