以自定义格式打印Solve的输出

时间:2019-07-15 17:00:49

标签: wolfram-mathematica

Solve[{A + B = 3, 2 A + B = 5}, {A, B}]

评估为A = 2, B = 1

我如何Print这样的结果

W = 2 + 1 * Sinx

1 个答案:

答案 0 :(得分:0)

研究https://reference.wolfram.com/language/ref/ReplaceAll.html,然后尝试

Print[W==A+B*Sinx/.Solve[{A+B==3, 2A+B==5}, {A,B}][[1]]]

可打印

W==2+Sinx

因为Mathematica自动将1 * Sinx简化为Sinx