Example 1:
> p = interpolate([| 1, 2, 3 |], [| 3, 5, 9 |]);
> write("p = ", p, "\n");
p = 3 + _x_ * (-1 + _x_)
Example 2:
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |]);
> write("p = ", p, "\n");
p = 21 + _x_ * (-100 / 3 + _x_ * (15.5 + _x_ * -13 / 6))
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |], 2^-17);
> write("p = ", p, "\n");
p = 21 + _x_ * (-33.333333492279052734375 + _x_ * (15.5 + _x_ * (-2.1666666567325592041015625)))
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |], 2^-17, [0; 2^42]);
> write("p = ", p, "\n");
p = 21 + _x_ * (-33.333333333333333333333333333333333333333333363228 + _x_ * (15.5 + _x_ * (-2.1666666666666666666666666666666666666666666647983)))
Example 3:
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |]);
> q = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |], 2^-17);
> delta = horner(p - q);
> write("delta = ", delta, "\n");
delta = _x_ * (1 / 6291456 + _x_^2 * -1 / 100663296)
> Delta = dirtyinfnorm(delta,[1;4]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 2.4471294368728034316556666925301338011322095712879e-7 = 2^(-21.962406251802890453634347359869541271899536019231)
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |]);
> q = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |], 2^-2000);
> delta = horner(p - q);
> write("delta = ", delta, "\n");
delta = _x_ * (1 / 4.4088218698531373730540794925222988186456999760206e604 + _x_^2 * -1 / 7.054114991765019796886527188035678109833119961633e605)
> Delta = dirtyinfnorm(delta,[1;4]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 3.4920910013773992744476948245123751988401933577684e-605 = 2^(-2007.9624062518028904536343473598695412718995360192)
Example 4:
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |]);
> q = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |], 2^-17, [0;2^10]);
> delta = horner(p - q);
> write("delta = ", delta, "\n");
delta = _x_ * (1 / 422212465065984 + _x_^2 * -1 / 6755399441055744)
> Delta = dirtyinfnorm(delta,[0;2^10]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 1.589432940818369388580322265625e-7 = 2^(-22.584984514668420136955755457026138868402791643092)
> p = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |]);
> q = interpolate([| 1, 2, 3, 4 |], [| 1, -1, 2, -3 |], 2^-2000, [0;2^10]);
> delta = horner(p - q);
> write("delta = ", delta, "\n");
delta = _x_ * (-1 / 3.6983878408024986992700435663608496048481867984446e611 + _x_^2 * 1 / 5.9174205452839979188320697061773593677570988775114e612)
> Delta = dirtyinfnorm(delta,[0;2^10]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 1.8145160239721784427448462541908690004638874174061e-604 = 2^(-2005.58498451466842013695575545702613886840279164307)
Example 5:
> p = interpolate([| 1, 2, 3, 4 |], 17 + _x_ * (42 + _x_ * (23 + _x_ * 1664)));
> write("p = ", p, "\n");
p = 17 + _x_ * (42 + _x_ * (23 + _x_ * 1664))
Example 6:
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_));
> write("p = ", p, "\n");
p = -1 * (-2 * (-3 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) + exp(2) - exp(1)) + exp(1) + _x_ * (-1 * (-2 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + -3 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) + -2 * (-3 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) + exp(2) - exp(1) + _x_ * (-1 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + -2 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + -3 * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3 + (exp(3) - exp(2) - (exp(2) - exp(1))) / 2 + _x_ * ((exp(4) - exp(3) - (exp(3) - exp(2))) / 2 - (exp(3) - exp(2) - (exp(2) - exp(1))) / 2) / 3))
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_), 2^-17);
> write("p = ", p, "\n");
p = -7.7172116227447986602783203125 + _x_ * (17.9146616198122501373291015625 + _x_ * (-9.7775724567472934722900390625 + _x_ * 2.2984042889438569545745849609375))
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_), 2^-17, [0; 2^42]);
> write("p = ", p, "\n");
p = -7.717211620141288536337557462573403702892010733189 + _x_ * (17.914661614969411928830253122773955194465923548481 + _x_ * (-9.7775724550214350407416860470959032694184512464826 + _x_ * 2.2984042886523568836092778582480142756017855238293))
Example 7:
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_));
> q = interpolate([| 1, 2, 3, 4 |], exp(_x_), 2^-17);
> delta = horner(p - q);
> Delta = dirtyinfnorm(delta,[1;4]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 7.8101123470606372346391215972092629613859312741733e-9 = 2^(-26.932009552561199842757802778211432954321538161928)
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_));
> q = interpolate([| 1, 2, 3, 4 |], exp(_x_), 2^-2000);
> delta = horner(p - q);
> Delta = dirtyinfnorm(delta,[1;4]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 3.574737886097255322676984068596786349480238060537e-606 = 2^(-2011.2505880400718258175558034736121948862189809702)
Example 8:
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_));
> q = interpolate([| 1, 2, 3, 4 |], exp(_x_), 2^-17, [0;2^10]);
> delta = horner(p - q);
> Delta = dirtyinfnorm(delta,[0;2^10]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 3.3174992022654716926120201737930257514243356389991e-9 = 2^(-28.167256735304970710773265696018465191273351786528)
> p = interpolate([| 1, 2, 3, 4 |], exp(_x_));
> q = interpolate([| 1, 2, 3, 4 |], exp(_x_), 2^-2000, [0;2^10]);
> delta = horner(p - q);
> Delta = dirtyinfnorm(delta,[0;2^10]);
> "Delta = ", Delta, " = 2^(", log2(Delta), ")";
Delta = 1.67480290063655159679957323422134460429582811153817e-605 = 2^(-2009.0225060850185477225876655278327362519640642038)
Example 9:
> f = exp(_x_);
> I = [-1/2;1/2];
> n = 17;
> X = [||]; for i from 0 to n do X = (~(1/2 * (inf(I) + sup(I)) + 1/2 * (sup(I) - inf(I)) * cos(pi * ((2 * i + 1)/(2 * (n + 1)))))) .: X; X = revert(X);
> p = interpolate(X, f, 2^-110);
> q = remez(f, n, I);
> Delta = dirtyinfnorm(p-f,I);
> "||p-f|| = ", Delta, " = 2^(", log2(Delta), ")";
||p-f|| = 4.6822823648740795415790209572324990540532715520787e-27 = 2^(-87.464846623211506004130540250100341126958424233896)
> Delta = dirtyinfnorm(q-f,I);
> "||q-f|| = ", Delta, " = 2^(", log2(Delta), ")";
||q-f|| = 4.5615560104462964431174181483603567519672456911095e-27 = 2^(-87.502532530192383004694428978646385337892102159012)
> Delta = dirtyinfnorm(horner(p-q),I);
> "||p-q|| = ", Delta, " = 2^(", log2(Delta), ")";
||p-q|| = 1.20729201910945452306513389470528343007256343110758e-28 = 2^(-92.742211980284523389260465711218526032152621095553)
Example 10:
> interpolate([| 1, 1 + 2^-1000 |], 17 + 42 * x);
17 + x * 42
> interpolate([| 1, 1 + 2^-10000 |], 17 + 42 * x);
17 + x * 42
> interpolate([| 1, 1 |], 17 + 42 * x);
error