Cody

Solution 1831218

Submitted on 30 May 2019
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   Fail
fh=@sin; x0=pi/4; h=1e-4; y_correct = 0.707106780007960; tol=1e-4; assert(abs(diffquot(fh,x0,h)-y_correct)<tol);

Undefined function or variable 'x'. Error in diffquot (line 2) y = x; Error in Test1 (line 4) assert(abs(diffquot(fh,x0,h)-y_correct)<tol);

2   Fail
fh=@(x) x^2+1; x0=2; h=1e-4; y_correct = 4.000000 tol=1e-4; assert(abs(diffquot(fh,x0,h)-y_correct)<tol);

y_correct = 4

Undefined function or variable 'x'. Error in diffquot (line 2) y = x; Error in Test2 (line 4) assert(abs(diffquot(fh,x0,h)-y_correct)<tol);

3   Fail
fh=@(x) 3*sqrt(x^2+1); x0=5; h=1e-4; y_correct = 2.941742027049443 tol=1e-4; assert(abs(diffquot(fh,x0,h)-y_correct)<tol);

y_correct = 2.9417

Undefined function or variable 'x'. Error in diffquot (line 2) y = x; Error in Test3 (line 4) assert(abs(diffquot(fh,x0,h)-y_correct)<tol);