Search code examples
pythonmathequationalgebrasage

Solving simultaneous equations in Sage


In Sage (using the Sage terminal in Sage Cloud), I expected the following to yield the result [t == (1/2)]. However, it yields the result [].

sage: var('x1 y1 x2 y2 t')
(x1, y1, x2, y2, t)
sage: eq1 = x1==t
sage: eq2 = y1==t
sage: eq3 = x2==t
sage: eq4 = y2==1-t
sage: solve([eq1,eq2,eq3,eq4,x1==x2,y1==y2],t)
[]

The following reformulation doesn't help:

sage: eq5 = x1==x2
sage: eq6 = y1==y2
sage: solve([eq1,eq2,eq3,eq4,eq5,eq6],t)
[]

Where am I going wrong?


Solution

  • If you write

    solve([eq1,eq2,eq3,eq4,x1==x2,y1==y2],t)
    

    Then t is the variable you are solving for and x1, x2, y1, y2 are free parameters. There is obviously no solution which is valid for any value of those parameter. However, if you ask:

    solve([eq1,eq2,eq3,eq4,x1==x2,y1==y2],t,x1,x2,y1,y2)
    

    Then you get what you expect:

    [[t == (1/2), x1 == (1/2), x2 == (1/2), y1 == (1/2), y2 == (1/2)]]