Ask Your Question
1

Using lagrange_polynomial() on points with variable coefficients

asked 2023-06-07 02:38:36 +0200

mrutkuokur gravatar image

updated 2023-06-07 13:07:58 +0200

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()

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-06-07 16:22:17 +0200

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)
edit flag offensive delete link more

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: 2023-06-07 02:38:36 +0200

Seen: 77 times

Last updated: Jun 07 '23