Cody

# Problem 1015. Polynomial Interpolation

Solution 858130

Submitted on 28 Mar 2016 by Peng Liu
• Size: 23
• This is the leading solution.
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
X = [4800; 5100]; Y = [7.5247; 7.2851]*1e-1; x = 5000; y = Poly_Interp(X,Y,x) y_correct = 0.73650; assert(abs(y-y_correct)<1e-4)

y = 0.7365

2   Pass
X = [4800; 5100]; Y = [7.5247; 7.2851]; x = 5000; y_correct = 7.3650; c_correct = 1.6350e+05; [y,c] = Poly_Interp(X,Y,x) assert(abs(y-y_correct)<1e-4) assert(norm(c-c_correct)<1e2)

y = 7.3650 c = 1.6350e+05

3   Pass
X = [300, 400, 500]; Y = [0.616, 0.525, 0.457]; x = 350; [y,c] = Poly_Interp(X,Y,x) y_correct = 0.567625; c_correct = [5.8932e+06]; assert(abs(y-y_correct)<1e-4) assert(norm(c-c_correct)<1e2)

y = 0.5676 c = 5.8932e+06

4   Pass
X = [1, 4 6]; Y = log(X); x = 2; [y,c] = Poly_Interp(X,Y,x) y_correct = 0.5658; c_correct = 93.9107; assert(abs(y-y_correct)<1e-4) assert(norm(c-c_correct)<1e-2)

y = 0.5658 c = 93.9107