Ask Your Question
1

Simplifying expression

asked 2022-10-27 11:30:36 +0200

Mosesxi gravatar image

Hello, I have expression that need to be simplified to the known terms. Below are the expression:

var('b0 a1 a2 h v_0 v_1 v_2 u_0 u_1 u_2');
expr = b0 == (16*h^2*v_0^2+(38*h*u_0-38*h*u_1)*v_0+25*u_1^2-50*u_0*u_1+25*u_0^2)/3;
expr.substitute(-h*v_0+2*u_1-2*u_0==a1,-2*(h*v_0-u_1+u_0)==a2)

The expected result is

b0 == c1*(a1)^q1 + c2*(a2)^q2

where c1, c2, q1, q2 are constants.

The output from Sage is

b0 == 16/3*h^2*v_0^2 + 25/3*u_0^2 - 50/3*u_0*u_1 + 25/3*u_1^2 + 38/3*(h*u_0 - h*u_1)*v_0
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-31 19:52:38 +0200

Max Alekseyev gravatar image

updated 2022-10-31 19:55:56 +0200

You'd better employ polynomial machinery here:

R.<b0, h, v_0, v_1, v_2, u_0, u_1, u_2, a1, a2> = PolynomialRing( QQ, order='lex' )
J = R.ideal( [-h*v_0+2*u_1-2*u_0 - a1, -2*(h*v_0-u_1+u_0) - a2] )
J.reduce( b0 - ( (16*h^2*v_0^2+(38*h*u_0-38*h*u_1)*v_0+25*u_1^2-50*u_0*u_1+25*u_0^2)/3 ) )

Notice that a0 and a1 comes last in the list of variables in R.<...> and so under the lexicographical order (order='lex') the other variables will be eliminated (by .reduce() function) in favor of using a1 and a2. The result of .redice() function is

b0 - a1^2 - 13/12*a2^2

which you may interpret as b0 == a1^2 + 13/12*a2^2 if you like.

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: 2022-10-27 11:30:36 +0200

Seen: 84 times

Last updated: Oct 31 '22