Ask Your Question
1

multivars eq ?

asked 2024-09-27 10:01:26 +0100

ortollj gravatar image

how do I get SageMath to give me both solutions?

# R.<theta_0,theta_1>=QQ[]
thetaVars=var('theta_0','theta_1')
aVars=var(['a_00', 'a_01', 'a_10', 'a_11'])
eqL=[]
eqL.append(3*theta_0^2 + 9*theta_0*theta_1 + 5*theta_1^2 == \
           a_00*theta_0^2 + a_01*theta_0*theta_1 + a_10*theta_0*theta_1 + a_11*theta_1^2)
eqL.append(-a_01*a_10 + a_00*a_11 == 1)

for eq in eqL :
    show(eq)
#how do I get SageMath to give me both solutions?    
# 2 solutions 
#s0=a_00==3,a_01==7,a_10==2,a_11==5
#s1=a_00==3,a_01==2,a_10==7,a_11==5
edit retag flag offensive close merge delete

Comments

Call solve(eqL,aVars) ?

Max Alekseyev gravatar imageMax Alekseyev ( 2024-09-27 12:50:16 +0100 )edit

W11,WSL UBUNTU SAGEMATH 10.2 solve(eqL,aVars) gives me something complicated, extract below:

[[a_00 == -1/2*((r1 + r2 - 9)*theta_0*theta_1 - 3*theta_0^2 - 5*theta_1^2 + sqrt(-6*(r1 + r2 - 9)*theta_0^3*theta_1 + (r1^2 - 2*(r1 + 9)*r2 + r2^2 - 18*r1 + 107)*theta_0^2*theta_1^2 - 10*(r1 + r2 - 9)*theta_0*theta_1^3 + 9*theta_0^4 + 25*theta_1^4))/theta_0^2, a_01 == r1, a_10 == r2, a_11 == -1/2*((r1 + r2 - 9)*theta_0*theta_1 - 3*theta_0^2 - 5*theta_1^2 - sqrt(-6*(r1 + r2 - 9)*theta_0^3*theta_1 + (r1^2 - 2*(r1 + 9)*r2 + r2^2 - 18*r1 + 107)*theta_0^2*theta_1^2 - 10*(r1 + r2 - 9)*theta_0*theta_1^3 + 9*theta_0^4 + 25*theta_1^4))/theta_1^2], [a_00 == -1/2*((r3 + r4 - 9)*theta_0*theta_1 - 3*theta_0^2 - 5*theta_1^2 - sqrt(-6*(r3 + r4 - 9)*theta_0^3*theta_1 + (r3^2 -
ortollj gravatar imageortollj ( 2024-09-27 13:17:13 +0100 )edit

human can solve this 2 equations very easily for aVars

ortollj gravatar imageortollj ( 2024-09-27 13:38:53 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-09-27 14:08:51 +0100

Max Alekseyev gravatar image

It looks like you want to treat the first equation as polynomial, meaning the equality of the coefficients for each monomial in theta's. If so, you need to add those equalities as individual equations:

R.<theta_0,theta_1> = SR[]
aVars=var(['a_00', 'a_01', 'a_10', 'a_11'])
eqL=[]
eqL.extend( ( 3*theta_0^2 + 9*theta_0*theta_1 + 5*theta_1^2 - \
(a_00*theta_0^2 + a_01*theta_0*theta_1 + a_10*theta_0*theta_1 + a_11*theta_1^2) ).coefficients() )
eqL.append(-a_01*a_10 + a_00*a_11 == 1)
show( solve(eqL,aVars) )

which gives exactly the two solutions you want.

edit flag offensive delete link more

Comments

Thank you @Max Alekseyev .

ortollj gravatar imageortollj ( 2024-09-27 15:58:13 +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: 2024-09-27 10:01:26 +0100

Seen: 186 times

Last updated: Sep 27