## IntroductionThis file contains an implementation of rational interpolation, where the data points are element of any integral domain. ## Questions and Outlook- Maybe this file should be joined with pinterp.spad, where polynomial
Lagrange interpolation is implemented. This version parallels the structure
of pinterp.spad closely. This also answers comments and questions from
wyscc. He remarked
- Abbreviations for a constructor should be limited to 7 letters (not 8). The system occasionally adds the 8th character to a package for internal use.
- Function names begin with a lower case, so RationalInterpolation should be rationalInterpolation, or better, rationalInterpolate.
- Regarding the types I used for the values, wyscc remarked
- If we are doing a rational interpolation, presumably the values are
rational, so it does not make sense to require the -coordinates of
inputs be integral. On the other hand, as in the above example, if one
uses
`FRAC INT` , problems can arise when this package is combined with other packages that constructs the quotient field of the parameter domain`F` because Axiom does not like constructing`FRAC FRAC INT` .
Note however, that the package would rather construct the type `FRAC SUP FRAC INT` , so this problem should not occur. Moreover, there are situations - for example in the package [mantepse.spad2]?, where we want to interpolate values from an IntegralDomain?. Of course we could first convert them to the quotient field, however, the current approach seems more natural to me. - If we are doing a rational interpolation, presumably the values are
rational, so it does not make sense to require the -coordinates of
inputs be integral. On the other hand, as in the above example, if one
uses
- Finally, wyscc asked:
If
`p(xx) = interpolate(lx, ly, m, k)` , what is the purpose of`elt(px, qx) = p(qx)` , the composition of`p(xx)` and`qx` , especially when`qx` is from`FRAC UP(xx, F)` instead of from just`F` ? and why is this function (the composition) also called`interpolate` ?I do not really know - apart from a very superficial level: Clearly, the second function was intended to let the user easily plug in values into the interpolated function. I don't find this sensible and I would be happy to change it. Indeed, this would also get rid of the first parameter to `RINTERP` , which is quite a nuisance.I think we should agree on a general interface for interpolation algorithms, and mark `PINTERP` as obsolete. By the way, it seems that`RINTERP` is faster, too. - There are probably better ways to implement rational interpolation. Maybe
http://www.cs.ucsb.edu/~omer/personal/abstracts/rational.html
contains something useful. In particular, in my package [mantepse.spad2]?, in
`guessRat` and`guessExpRat` I generate interpolating polynomials for all possible degrees of numerator and denominator. The above article contains an algorithm that does this in time , which would be quite nice. Currently, I need operations for*each*degree! - For polynomial interpolation, there seems to be an algorithm that needs only operations. It can be found in van zur Gathen's book "Modern computer algebra", chapter 10.
- For those who speak german, http://www.num.math.uni-goettingen.de/schaback/teaching/numath.ps contains quite a bit of information.
- This implementation of rational interpolation neither takes care of unattainable points, nor does it check whether the values of the -coordinates are all distinct.
- Comments welcome!
spad )abbrev package RINTERPA RationalInterpolationAlgorithms ++ Description: ++ This package exports rational interpolation algorithms RationalInterpolationAlgorithms(F, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/959208282017174297-25px001.spad using old system compiler. RINTERPA abbreviates package RationalInterpolationAlgorithms ******** Spad syntax error detected ******** The prior line was: spad )abbrev package RINTERP RationalInterpolation ++ Description: ++ This package exports interpolation algorithms RationalInterpolation(xx, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6898989268314666018-25px002.spad using old system compiler. RINTERP abbreviates package RationalInterpolation ------------------------------------------------------------------------ initializing NRLIB RINTERP for RationalInterpolation compiling into NRLIB RINTERP processing macro definition RIA ==> RationalInterpolationAlgorithms compiling exported interpolate : (Fraction UnivariatePolynomial(xx, First we check whether we have the right number of points and values. Clearly the number of points and the number of values must be identical. Note that we want to determine the numerator and denominator polynomials only up to a factor. Thus, we want to determine coefficients, where is the degree of the polynomial in the numerator and is the degree of the polynomial in the denominator. In fact, we could also leave - for example - unspecified and determine it as : I don't know whether this would be better. The next step is to set up the matrix. Suppose that our numerator polynomial is and that our denominator polynomial is . Then we have the following equations, writing for : We generate this matrix columnwise, then we can solve the system using Note that it may happen that the system has several solutions. In this case, some of the data points may not be interpolated correctly. However, the solution is often still useful, thus we do not signal an error. Since all the solutions of ## ExamplesTo conclude we present some examples. To begin with, the following interpolation illustrates the concept of unattainable points: fricas interpolate([q,
Type: Fraction(Polynomial(Fraction(Polynomial(Integer))))fricas f(x) == (x^3+5*x-3)/(x^2-3) Type: Voidfricas xlist := [1/2,
Type: List(Fraction(Integer))fricas ylist := [f(x) for x in xlist] fricas Compiling function f with type Fraction(Integer) -> Fraction(Integer )
Type: List(Fraction(Integer))fricas interpolate(xlist,
Type: Fraction(Polynomial(Fraction(Integer)))fricas interpolate(1/6::FRAC UP(x, A harder example: fricas dom := DMP([z], Type: Typefricas g: FRAC dom -> FRAC dom; Type: Voidfricas g(x) == (x^3*z+5*z^2*x -3*z^3)/(z*x^2 - 3) Type: Voidfricas xxlist: List FRAC dom := [1/(2*z),
fricas yylist := [g(x) for x in xxlist] fricas Compiling function g with type Fraction( DistributedMultivariatePolynomial([z],
fricas interpolate(xxlist,
fricas interpolate(4*z::FRAC UP(x, |