Problem 47583. Approximation of an integral - Riemann sum
Riemann sum is a certain kind of approximation of an integral by a finite sum.
In this problem, I want you to use Midpoint Riemann sum to integrate a function.
As a test case, we should know that the integral of cos(x) over the interval [0,pi/2] is 1. Code numerical code, has only known spacing of the interval:
dx = pi/10;
x=0:dx:pi/2;
fx = cos(x([1:end-1])+dx/2)
riemannInt(fx,deltax)
ans =
1.004124203953987
Round the answer according to the test suite
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers19
Suggested Problems
-
Magic is simple (for beginners)
10216 Solvers
-
ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
569 Solvers
-
Test if a number is numeric or not
138 Solvers
-
Combined Ages 1 - Symmetric, n = 3
270 Solvers
-
9872 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!