Ask Your Question
1

Using lagrange_polynomial() on points with variable coefficients

asked 1 year ago

mrutkuokur gravatar image

updated 1 year ago

Is it possible to modify lagrange_polynomial so that it accepts points with variable entries? I was able to make it work on a small example, by disabling the coercion functions in the source file "polynomial_ring.py", but then the program failed on a finite field.

y = var("y")
T = PolynomialRing(QQ, 'x')
f = T.lagrange_polynomial([(0,y),(2,2)])
print(f)

returns:

TypeError: unable to convert y to a rational

Documentation for lagrange_polynomial()

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 1 year ago

Max Alekseyev gravatar image

y must belong to the base ring of the polynomial. Hence a simple fix in this case is to define T over SR rather than QQ:

y = var("y")
T = PolynomialRing(SR, 'x')
f = T.lagrange_polynomial([(0,y),(2,2)])
print(f)
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 1 year ago

Seen: 181 times

Last updated: Jun 07 '23