Question: % Your task for this lab assignment is to correctly implement % the functions called by integration 1 : % leftriemannsum, rightriemannsum, and midpointriemannsum %
Your task for this lab assignment is to correctly implement
the functions called by integration:
leftriemannsum, rightriemannsum, and midpointriemannsum
based on their comments, provided code, and examples.
The function integration assumes arg is a floating point number a
The function integration assumes arg is a floating point number b
The function integration assumes arg is an integer for n
This function assumes a b and n
The function integration is already implemented for you to have
consistent IO with our examples. After you finish implementing
the functions aforementioned, you should not change the source
code in integration
function integrationarg arg arg
a strnumarg;
b strnumarg;
n ceilstrnumarg;
fprintfLet fxex
;
fprintfApproximating the integral of fx over the interval
;
fprintfff for n i
a b n;
approx leftriemannsuma b n;
absError absoluteerrorapprox a b;
fprintfLeft hand Riemann sum f absolute error f
approx, absError;
approx rightriemannsuma b n;
absError absoluteerrorapprox a b;
fprintfRight hand Riemann sum f absolute error f
approx, absError;
approx midpointriemannsuma b n;
absError absoluteerrorapprox a b;
fprintfMidpoint Riemann sum f absolute error f
approx, absError;
end
Return sum, the left hand Riemann sum
of fx from a to b using n rectangles.
You should call fx to implement this function.
Do not use any builtin Matlab functions
to implement this function.
function sum leftriemannsuma b n
end
Return sum, the right hand Riemann sum
of fx from a to b using n rectangles.
You should call fx to implement this function.
Do not use any builtin Matlab functions
to implement this function.
function sum rightriemannsuma b n
end
Return sum, the midpoint Riemann sum
of fx from a to b using n rectangles.
You should call fx to implement this function.
Do not use any builtin Matlab functions
to implement this function.
function sum midpointriemannsuma b n
end
Return y f evaluated at x
Call this function to implement
the other functions above.
You should not change this function.
function y fx
y expx;
end
Return absError the absolute error between v and
the area under the curve for fx over a b
You should not change this function.
function absError absoluteerrorv a b
area pierfa erfb;
absError absv area;
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
