在Sage中求解联立方程 [英] Solving simultaneous equations in Sage
本文介绍了在Sage中求解联立方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 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)
[]
我要去哪里错了?
推荐答案
如果您写
solve([eq1,eq2,eq3,eq4,x1==x2,y1==y2],t)
然后t
是您要求解的变量,而x1, x2, y1, y2
是免费参数.显然,没有解决方案对于这些参数的任何值都有效.但是,如果您问:
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)]]
这篇关于在Sage中求解联立方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文