Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%% 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)
y =
0.7365
|
2 | Pass |
%% 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)
y =
7.3650
b =
7.5247 -0.0008
|
3 | Pass |
%% 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)
y =
0.5676
b =
0.6160 -0.0009 0.0000
|
4 | Pass |
%% 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)
y =
0.5658
b =
0 0.4621 -0.0519
|
Return the 3n+1 sequence for n
6166 Solvers
Back to basics 21 - Matrix replicating
1052 Solvers
What is the distance from point P(x,y) to the line Ax + By + C = 0?
277 Solvers
Top of the Hour : Return from your routine within 1 second of the hour
21 Solvers
Golomb's self-describing sequence (based on Euler 341)
106 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!