Cody

Solution 2351513

Submitted on 24 May 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
deltax = pi/12; Fx = cos(linspace(0,pi/2,7)); y_correct = 1.00002631217059; tol = 1e-14; assert(abs(simpsInt(Fx,deltax) - y_correct) < tol)

y = 1.0000

2   Pass
deltax = 0.125; Fx = exp((0:8)/8); y_correct = 1.7182841546999; tol = 1e-14; assert(abs(simpsInt(Fx,deltax) - y_correct) < tol)

y = 1.7183

3   Pass
deltax = 1; Fx = (0:10).^2; y_correct = 1000/3; tol = 1e-11; assert(abs(simpsInt(Fx,deltax) - y_correct) < tol)

y = 333.3333

4   Pass
deltax = 1; Fx = (0:10).^4; y_correct = 20001.3333333333333; tol = 1e-9; assert(abs(simpsInt(Fx,deltax) - y_correct) < tol)

y = 2.0001e+04

5   Pass
deltax = 1; Fx = sin(-5:5); y_correct = 0; tol = 1e-15; assert(abs(simpsInt(Fx,deltax) - y_correct) < tol)

y = -1.8504e-17

6   Fail
deltax = 0.25; Fx = sin(0:.25:100); y_correct = 0.13768413796203; tol = 1e-15; assert(abs(simpsInt(Fx,deltax) - y_correct) < tol)

y = 0.1377

Assertion failed.

7   Pass
deltax = 1; Fx = double((0:10) >= 5); y_correct = 5.66666666666667; tol = 1e-14; abs(simpsInt(Fx,deltax) - y_correct) < tol

y = 5.6667 ans = logical 1