Question: MATLAB Write a function trap(f,a,b,n) that computes the trapezoidal rule approximation to where h = (b-a) and x i = a + ih. Test your
MATLAB
Write a function trap(f,a,b,n) that computes the trapezoidal rule approximation to 

where h = (b-a) and xi = a + ih. Test your function on sin(x) + cos(x) for
.
For a greater challenge, write a function simp for Simpson's rule,

This formula requires n to be even. You may choose to check the input for this. Use comment lines, starting with "%" in MATLAB.
f(x)dx
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
