问题描述
我正在尝试写下我的工作笔记.Maxima 简化我的工作的方式是,一旦我写了一堆方程,我想改变一个变量的定义,我就这样做并重新评估整个文件.
I'm trying to write down some notes of my work. The way Maxima would simplify my work is that once I write bunch of equations and I want to change the definition of a variable, I do it and re-evaluate the entire file.
以下是我尝试完成的示例:
Here is an example of what I'm trying to accomplish:
问题 1:我有一个方程组,我想从 Maxima 得到的只是变量替换.
Question 1:I have a system of equations and all I want from Maxima is just variables replacement.
eq1: x=a+b+c
eq2: y=d+e+f
eq3: x+y=0
如何让 Maxima 输出
How do I get Maxima to output
eq3: a+b+c+d+e+f = 0
所以以后如果我想让 x 变成 a+b-c,我就改变它并重新评估
So in the future if I want x to be a+b-c, I just change it and re-evaluate
问题 2:与之前类似,但稍微复杂一些
Question 2:Similar to before but a bit more complex
eq1: x=a+b+c
eq2: y=d+e+f
eq3: x=y
eq4: a+s+e=0
如何让 Maxima 输出
How do I get Maxima to output
eq3 a+b+c=d+e+f
如何让 Maxima 为 a 求解 eq1 并为 e 和输出求解 eq2
How do I get Maxima to solve eq1 for a and solve eq2 for e and output
eq4: x-b-c+s+y-d-f = 0
预先感谢您的帮助,圭多
Thank you in advance for your help,Guido
推荐答案
我认为 subst
和 solve
可以在这里处理你想要的操作.
I think subst
and solve
can handle the operations you want here.
(%i1) eq1: x=a+b+c;
(%o1) x = c + b + a
(%i2) eq2: y=d+e+f;
(%o2) y = f + e + d
(%i3) eq3: x+y=0;
(%o3) y + x = 0
(%i4) subst ([eq1, eq2], eq3);
(%o4) f + e + d + c + b + a = 0
好的,现在这是您的第二个示例.注意 solve
返回一个方程列表.
OK, now here's your second example. Note that solve
returns a list of equations.
(%i5) eq3: x=y;
(%o5) x = y
(%i6) eq4: a+s+e=0;
(%o6) s + e + a = 0
(%i7) subst ([eq1, eq2], eq3);
(%o7) c + b + a = f + e + d
(%i8) solve (eq1, a);
(%o8) [a = x - c - b]
(%i9) solve (eq2, e);
(%o9) [e = y - f - d]
(%i10) append (%o8, %o9);
(%o10) [a = x - c - b, e = y - f - d]
(%i11) subst (%o10, eq4);
(%o11) y + x + s - f - d - c - b = 0
Maxima 的solve
功能不是太强大;它不能解的方程有很多种.但它可以解线性方程.
Maxima's solve
function is not too powerful; there are many kinds of equations it cannot solve. But it can solve linear equations.
这篇关于Maxima:如何替换方程中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!