how to initialize lagrange_polynomial command for Finite Ring . It works for Finite Field,Z and Q . I tried for Ring with finite order, for me its shows ERROR.here is the code:
R = PolynomialRing(Zmod(8), 'x')
R.lagrange_polynomial([(1,2),(2,3),(3,4),(4,5),(5,6),(7,0),(0,1)])
It shows " Attribute Error, Couldn't use Lagrange here". don't know Why . Can anyone help me to fix the Error. Thank you in advance.
Welcome to MSE! For future reference, these kinds of sage questions might get answered more quickly at ask.sagemath.org, but since you're here I'll happily answer it ^_^.
The issue is that lagrange interpolation only works over a field, which $\mathbb{Z}/8$ notably isn't. When we do lagrange interpolation we have to divide. For instance, say you want to find a line connecting $(1,1)$ and $(3,1)$ in $\mathbb{Z}/8$. Then the method outputs the polynomial
$$ \frac{x-1}{3-1} + \frac{x-3}{1-3} = \frac{x-1}{2} - \frac{x-3}{2} $$
of course, we can't invert $2$ in $\mathbb{Z}/8$!
This is a toy example (obviously the constant $1$ polynomial interpolates these two points) but it showcases the problems with lagrange interpolation over rings that aren't integral domains.
I hope this helps ^_^