Piecewise linear interpolationΒΆ

We generate a piecewise linear interpolant of \(f(x)=e^{\sin 7x}\).

using FundamentalsNumericalComputation
f = x -> exp(sin(7*x))


First we sample the function to create the data.

t = [0, 0.075, 0.25, 0.55, 0.7, 1]    # nodes
y = f.(t)                             # function values


Now we create a callable function that will evaluate the piecewise linear interpolant at any \(x\).

p = FNC.plinterp(t,y)
plot!(p,0,1,label="interpolant",title="PL interpolation")