Find the quadratic spline $s(t)$, with $z_0 = 0$, for points $[t, 1/(1+t^2)]$ with the knots $t = 0, 1, 2, 3, 4$

47 Views Asked by At

Find the maximum of

$[s(t + .5) − 1/(1 + (t + .5)^2)]$ for $t = 0, 1, 2, 3, 4$.

My code so far:

t = {  0, 1, 2, 3, 4};
y = {1, .5, .2, .1, (1/17)};


n = Length[t];
z = y;
z[[0]] = 0;   
For[i = 2, i <= n, i++,
    z[[i]] = -z[[i - 1]] + 
    2 (y[[i]] - y[[i - 1]])/(t[[i]] - t[[i - 1]])];

spline2[x_] :=
 Module[{i, j},
  i = 0;
  For[j = 1, j < n, j++,
   If[x < t[[j + 1]], i = j; Break[]]];
  If[i == 0, i = n - 1];
  (x - t[[i]]) ((x - t[[i]]) (z[[i + 1]] - z[[i]])/(2 (t[[i + 1]] - t[[i]])) + z[[i]]) + y[[i]]]

Using a template for an example spline question, not sure where to put the s(t+.5)-1/(1+(t+.5)2 to calculate the maximums