/usr/share/axiom-20170501/src/algebra/PINTERPA.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | )abbrev package PINTERPA PolynomialInterpolationAlgorithms
++ Description:
++ This package exports interpolation algorithms
PolynomialInterpolationAlgorithms(F, P) : SIG == CODE where
F : Field
P : UnivariatePolynomialCategory(F)
SIG ==> with
LagrangeInterpolation : (List F, List F) -> P
++ LagrangeInterpolation(l1,l2) \undocumented
CODE ==> add
LagrangeInterpolation(lx, ly) ==
#lx ^= #ly =>
error "Different number of points and values."
ip: P := 0
for xi in lx for yi in ly for i in 0.. repeat
pp: P := 1
xp: F := 1
for xj in lx for j in 0.. | i ^= j repeat
pp := pp * (monomial(1,1) - monomial(xj,0))
xp := xp * (xi - xj)
ip := ip + (yi/xp) * pp
ip
|