Ask Your Question
1

Change of variables in symbolic computation

asked 2021-11-02 19:11:58 +0100

klx gravatar image

I need to change Y into 1/2 *( y - a1 * x - a3) so that I can change variables in Elliptic curves.

var("X,Y,Z,x,y,a1,a2,a3,a4,a5,a6")
F = Y^2  *Z + a1 * X*Y *Z + a3 *Y *Z^2 - X^3 - a2 *X^2 * Z + a4*X*Z^ 2 + a6*Z^3
print(F)
F.substitute_expression(Y == 1/2 *( y - a1 * x - a3))  
print(F)

This produces an error on the 4th line;

AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'substitute_expression'

What is the proper way to change the variables?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-11-03 05:22:41 +0100

slelievre gravatar image

Use subs or substitute.

sage: var("X,Y,Z,x,y,a1,a2,a3,a4,a5,a6")
(X, Y, Z, x, y, a1, a2, a3, a4, a5, a6)
sage: F = Y^2  *Z + a1 * X*Y *Z + a3 *Y *Z^2 - X^3 - a2 *X^2 * Z + a4*X*Z^ 2 + a6*Z^3
sage: F
X*Y*Z*a1 - X^2*Z*a2 + Y*Z^2*a3 + X*Z^2*a4 + Z^3*a6 - X^3 + Y^2*Z
sage: F.subs(Y == 1/2 *( y - a1 * x - a3))
-1/2*(a1*x + a3 - y)*X*Z*a1 - X^2*Z*a2 - 1/2*(a1*x + a3 - y)*Z^2*a3
+ X*Z^2*a4 + Z^3*a6 - X^3 + 1/4*(a1*x + a3 - y)^2*Z
edit flag offensive delete link more

Comments

I guess substitute_expression is for something else, however, I couldn't find it in the docs.

klx gravatar imageklx ( 2021-11-03 18:59:39 +0100 )edit

Also, I've seen this answer of yours and the function is not working, at least for me. Something has changed with Python3?

klx gravatar imageklx ( 2021-11-03 19:04:16 +0100 )edit

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: 2021-11-02 19:11:58 +0100

Seen: 148 times

Last updated: Nov 03 '21