Ask Your Question
0

number of arguments does not match number of variables in parent

asked 2023-12-05 16:12:37 +0100

Rellw gravatar image

updated 2023-12-06 14:34:47 +0100

FrédéricC gravatar image

Thanks a lot for your reading and help. I want to calculate one polynomial in 6 variables, arising from elliptic curves. I use two methods. These are my code.

1.

sage: R.<x, y, a1, a2, a3, a4>= RationalField()[];R

Multivariate Polynomial Ring in x, y, a1, a2, a3, a4 over Rational Field

sage: a1(3*x^2+2*a2*x+a4-a1*y)(2*y+a1*x+a3)-(a2+2*x)(2*y+a1*x+a3)^2+(3*x^2+2*a2*x+a4-a1*y)^2

----------------------------------------------------------------------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-d31ceec0d0e8> in <module>
----> 1 a1(Integer(3)*x**Integer(2)+Integer(2)*a2*x+a4-a1*y)(Integer(2)*y+a1*x+a3)-(a2+Integer(2)*x)(Integer(2)*y+a1*x+a3)**Integer(2)+(Integer(3)*x**Integer(2)+Integer(2)*a2*x+a4-a1*y)**Integer(2)

/usr/lib/python3/dist-packages/sage/rings/polynomial/multi_polynomial_libsingular.pyx in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.__call__ (build/cythonized/sage/rings/polynomial/multi_polynomial_libsingular.cpp:20530)()
   2116
   2117         if l != parent._ring.N:
-> 2118             raise TypeError("number of arguments does not match number of variables in parent")
   2119
   2120         try:

TypeError: number of arguments does not match number of variables in parent

2.

sage: PolynomialRing(RationalField(),6,'a')

Multivariate Polynomial Ring in a0, a1, a2, a3, a4, a5 over Rational Field

sage: a1(3*a0^2+2*a2*a5+a4-a1*a5)(2*a5+a1*a0+a3)-(a2+2*a0)(2*a5+a1*a0+a3)^2+(3*a0^2+2*a2*a0+a4-a1*a5)^2

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-157192839bba> in <module>
----> 1 a1(Integer(3)*a0**Integer(2)+Integer(2)*a2*a5+a4-a1*a5)(Integer(2)*a5+a1*a0+a3)-(a2+Integer(2)*a0)(Integer(2)*a5+a1*a0+a3)**Integer(2)+(Integer(3)*a0**Integer(2)+Integer(2)*a2*a0+a4-a1*a5)**Integer(2)

NameError: name 'a0' is not defined

Could anyone tell me how to make it work? Thanks very much!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2023-12-05 18:36:09 +0100

Max Alekseyev gravatar image

updated 2023-12-05 19:54:03 +0100

You have missing multiplications symbols (*). In particular, a1(...) makes Sage think that you are evaluating polynomial a1 on some arguments.

Corrected code #1 is

R.<x, y, a1, a2, a3, a4>= RationalField()[];R
a1*(3*x^2+2*a2*x+a4-a1*y)*(2*y+a1*x+a3)-(a2+2*x)*(2*y+a1*x+a3)^2+(3*x^2+2*a2*x+a4-a1*y)^2

In code #2, you need additionally to declare the polynomial variables, which can be done by calling .inject_variables():

R = PolynomialRing(RationalField(),6,'a')
R.inject_variables()
a1*(3*a0^2+2*a2*a5+a4-a1*a5)*(2*a5+a1*a0+a3)-(a2+2*a0)*(2*a5+a1*a0+a3)^2+(3*a0^2+2*a2*a0+a4-a1*a5)^2
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

1 follower

Stats

Asked: 2023-12-05 16:12:37 +0100

Seen: 130 times

Last updated: Dec 05 '23