Solving simultaneous equations in Sage

萝らか妹 提交于 2019-12-23 04:26:42

问题


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?


回答1:


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)]]


来源:https://stackoverflow.com/questions/22180968/solving-simultaneous-equations-in-sage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!