gpt4 book ai didi

maxima - 如何将 solve in maxima 的输出分配给变量?

转载 作者:行者123 更新时间:2023-12-04 16:51:26 24 4
gpt4 key购买 nike

我正在使用 xmaxima 使用“求解”命令求解两个联立非线性方程。显示的答案是 x=[ans1, ans2,..], y=[ans1,ans2,...], 但是它被存储到变量 'x' 和 'y' 中。如何将输出分配给变量,以便我可以使用输出进行进一步计算。xmaxima代码如下:

A:0.500000000000000$
B:0.709506070053745$
C:0.242527534593605$
D:0.719012140107490$
E: 0.357164044380080$
F:-0.505315948652670$
G:0.181895650945204$
H: 0.300000000000000$

[x,y]=solve([x^2*(A*y^3+B*y-C)-D*x*y^2+E*y^3,A*x^2+(x/y^2)*(H*y+G)+F],[x,y]),numer;

output is:
[x, y] = [[x = 0.0611142802814223, y = 0.167915465898175],
[x = - 6.026109660574413, y = 0.305609155632444],
[x = 0.290917101108745, y = 0.445210848095313],
[x = 0.456144541234576 %i + 1.180400965797426,
y = 0.869595022612534 %i + 0.051360830266336],
[x = 1.180400965797425 - 0.456144541234575 %i,
y = 0.051360830266336 - 0.869595022612534 %i],
[x = 0.0609759975012744 %i - 0.777728688525087,
y = 0.792517145089706 %i - 0.51072855430292],
[x = - 0.0609759975012744 %i - 0.777728688525087,
y = - 0.792517145089706 %i - 0.51072855430292],
[x = 0, y = 0]]

最佳答案

首先,请注意解决方案不止一种,因此您必须决定要用它们做什么。一种选择如下:

(%i9) solutions: solve([x^2*(A*y^3+B*y-C)-D*x*y^2+E*y^3,A*x^2+(x/y^2)*(H*y+G)+F],[x,y]), numer$

<snipped some info lines from rat>

(%i10) xvals: map(rhs, map(first, solutions));
(%o10) [.06111426947129051, - 6.026109660574413, .2909171173159695,
.4561445354339108 %i + 1.180400961416986,
1.180400961416985 - .4561445354339104 %i,
.06097600174281474 %i - 0.77772869099467,
- .06097600174281463 %i - 0.77772869099467, 0]

(%i11) yvals: map(rhs, map(second, solutions));
(%o11) [.1679154401926679, .3056091599125177, .4452108480953128,
.8695950265919334 %i + .05136082885038127,
.05136082885038127 - .8695950265919334 %i,
0.792517152411182 %i - .5107285531053073,
- 0.792517152411182 %i - .5107285531053073, 0]

然后您可以通过 xvals[k]yvals[k] 获取 x,y 对的解决方案(您可以在 1 到 8 之间选择 k ).

关于maxima - 如何将 solve in maxima 的输出分配给变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9765715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com