import mir.math.common: approxEqual; alias f = (double x) => 3 * x ^^ 3 + 7 * x ^^ 2 + 5 * x + 10; alias d = (double x) => 3 * 3 * x ^^ 2 + 2 * 7 * x + 5; alias s = (double x) => 6 * 3 * x + 2 * 7; auto x0 = 4; auto x1 = 9; auto p = CubicKernel!double.fromSecondAndFirstDerivative(x0, x1, f(x0), f(x1), s(x0), d(x1)); assert(p.a.approxEqual(3)); assert(p.b.approxEqual(7)); assert(p.c.approxEqual(5)); assert(p.d.approxEqual(10)); assert(p(13).approxEqual(f(13))); assert(p.opCall!1(13)[1].approxEqual(d(13))); assert(p.opCall!2(13)[2].approxEqual(s(13))); assert(p.opCall!3(13)[3].approxEqual(18));
Cubic function structure