File:Quadratic interpolation.svg

Summary

Description
English: example of quadratic interpolation
Date
Source Own work
Author User:DaBler

Licensing

Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
Category:Self-published work#Quadratic%20interpolation.svgCategory:PD-self#Quadratic%20interpolation.svg

Source code

Plotted in GNU Octave:

clear;

figure(1);
subplot(211);
hold off;

x = [-1 0 1];
y = [-1 3 2];

stem( x, y );
hold on;

a = (y(1)-2*y(2)+y(3))/2;
b = (y(3)-y(1))/2;
c = y(2);

t = [-2000:+2000]./1000;

p = a*t.*t+b*t+c;

plot( t, p );

t_max = -b/2/a;
p_max = a*t_max.*t_max+b*t_max+c;

h=stem( t_max, p_max, "r" );

ylim([-2 5]);
xlim([-2 2])

legend("f[x]", "f(x)", "f(x) = max")
xlabel("x");
ylabel("y","Rotation",0);

subplot(212);
hold off;
plot( t(1:end-1), diff(p,1) );
hold on;
h=stem(t_max, 0, "r");

xlim([-2 2])
legend("f'(x)", "f'(x) = 0")
xlabel("x");
ylabel("y","Rotation",0);

print("quadratic_interpolation.svg");
Category:Interpolation Category:Created with GNU Octave Category:Images with Octave source code
Category:Created with GNU Octave Category:Images with Octave source code Category:Interpolation Category:PD-self Category:Self-published work