First time here? Check out the FAQ!

Ask Your Question
1

multivars eq ?

asked 0 years ago

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
Preview: (hide)

Comments

Call solve(eqL,aVars) ?

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )

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 ( 0 years ago )

human can solve this 2 equations very easily for aVars

ortollj gravatar imageortollj ( 0 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

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.

Preview: (hide)
link

Comments

Thank you @Max Alekseyev .

ortollj gravatar imageortollj ( 0 years ago )

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: 0 years ago

Seen: 203 times

Last updated: Sep 27 '24