Cody

Solution 156833

Submitted on 1 Nov 2012
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
%% Check linear interpolation X = [4800; 5100]; Y = [7.5247; 7.2851]*1e-1; x = 5000; y = Newton_Interp(X,Y,x) y_correct = 0.73650; assert(abs(y-y_correct)<1e-4)
Error: Undefined function or variable "y".
2   Fail
%% Check Newton polynomial coefficients X = [4800; 5100]; Y = [7.5247; 7.2851]; x = 5000; y_correct = 7.3650; b_correct = [7.5247, -0.00079867]; [y,b] = Newton_Interp(X,Y,x) assert(abs(y-y_correct)<1e-4) assert(norm(b-b_correct)<1e-3)
Error: Undefined function or variable "y".
3   Fail
%% Check quadratic interpolation X = [300, 400, 500]; Y = [0.616, 0.525, 0.457]; x = 350; [y,b] = Newton_Interp(X,Y,x) y_correct = 0.567625; b_correct = [0.616, -0.00091, 0.00000115]; assert(abs(y-y_correct)<1e-4) assert(norm(b-b_correct)<1e-3)
Error: Undefined function or variable "y".
4   Fail
%% Check quadratic interpolation for log X = [1, 4 6]; Y = log(X); x = 2; [y,b] = Newton_Interp(X,Y,x) y_correct = 0.5658; b_correct = [0, 0.4620981, -0.0518731]; assert(abs(y-y_correct)<1e-4) assert(norm(b-b_correct)<1e-3)
Error: Undefined function or variable "y".