1

我正在尝试x_Trag, y_Trag, x_Zug, y_Zug用四个方程式解决四个未知变量eqx, eqy, Py_Trag, Py_Zug。可悲的是,只有简单的测试用例在起作用。

这是 Wxmaxima 粘贴:

(%i1)   kill(all); load(ezunits);
Warning: Can set maxima's working directory but cannot change it during the maxima session :

(%o0)   done

(%o1)   "C:/maxima-5.44.0/share/maxima/5.44.0/share/ezunits/ezunits.mac"
  1 easy values work
  1.1 vars
(%i2)   x_GG: 1`mm;
(x_GG)  1 ` mm
(%i3)   y_GG: 18`mm;
(y_GG)  18 ` mm
(%i4)   L_HR: 5`mm;
(L_HR)  5 ` mm
(%i5)   L_Trag: 5`mm;
(L_Trag)    5 ` mm
(%i6)   L_Zug: 15`mm;
(L_Zug) 15 ` mm
(%i7)   x_HR: 4`mm;
(x_HR)  4 ` mm
(%i8)   y_HR: 3`mm;
(y_HR)  3 ` mm
  1.2 equations
(%i9)   eqx: x_Zug=x_GG+x_HR+x_Trag;
(eqx)   x_Zug=x_Trag+5 ` mm
(%i10)  eqy: y_GG=y_HR+y_Zug+y_Trag;
(eqy)   18 ` mm=y_Zug+y_Trag+3 ` mm
(%i11)  Py_Trag: L_Trag^2=x_Trag^2+y_Trag^2;
(Py_Trag)   25 ` mm^2=y_Trag^2+x_Trag^2
(%i12)  Py_Zug: L_Zug^2=x_Zug^2+y_Zug^2;
(Py_Zug)    225 ` mm^2=y_Zug^2+x_Zug^2
  1.3 solving works
(%i13)  res: dimensionally(solve([eqx, eqy, Py_Trag, Py_Zug], [x_Trag, y_Trag, x_Zug, y_Zug]))[1];
(res)   [x_Trag=4 ` mm,y_Trag=3 ` mm,x_Zug=9 ` mm,y_Zug=12 ` mm]
  2 but not the ones I need
  2.1 vars
(%i14)  x_GG: 2`mm;
(x_GG)  2 ` mm
(%i15)  y_GG: 193`mm;
(y_GG)  193 ` mm
(%i16)  L_HR: 46`mm;
(L_HR)  46 ` mm
(%i17)  L_Trag: 50`mm;
(L_Trag)    50 ` mm
(%i18)  L_Zug: 190`mm;
(L_Zug) 190 ` mm
(%i19)  x_HR: 46*cos((149*%pi-360*acos(1/3))/360) ` mm;
(x_HR)  46*cos((149*%pi-360*acos(1/3))/360) ` mm
(%i20)  y_HR: 46*sin((149*%pi-360*acos(1/3))/360) ` mm;
(y_HR)  46*sin((149*%pi-360*acos(1/3))/360) ` mm
  2.2 equations
(%i21)  eqx: x_Zug=x_GG+x_HR+x_Trag;
(eqx)   x_Zug=x_Trag+(46*cos((149*%pi-360*acos(1/3))/360)+2) ` mm
(%i22)  eqy: y_GG=y_HR+y_Zug+y_Trag;
(eqy)   193 ` mm=y_Zug+y_Trag+46*sin((149*%pi-360*acos(1/3))/360) ` mm
(%i23)  Py_Trag: L_Trag^2=x_Trag^2+y_Trag^2;
(Py_Trag)   2500 ` mm^2=y_Trag^2+x_Trag^2
(%i24)  Py_Zug: L_Zug^2=x_Zug^2+y_Zug^2;
(Py_Zug)    36100 ` mm^2=y_Zug^2+x_Zug^2
  2.3 solving takes very long, but dosen't find a solution
(%i26)  res: dimensionally(solve([eqx, eqy, Py_Trag, Py_Zug], [x_Trag, y_Trag, x_Zug, y_Zug])); float(%);
(res)   []
(%o26)  []

wxm-file,应该更适合粘贴:

/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
/* [ Created with wxMaxima version 21.02.0 ] */
/* [wxMaxima: input   start ] */
kill(all); load(ezunits);
/* [wxMaxima: input   end   ] */


/* [wxMaxima: section start ]
easy values work
   [wxMaxima: section end   ] */


/* [wxMaxima: subsect start ]
vars
   [wxMaxima: subsect end   ] */


/* [wxMaxima: input   start ] */
x_GG: 1`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
y_GG: 18`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_HR: 5`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_Trag: 5`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_Zug: 15`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
x_HR: 4`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
y_HR: 3`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: subsect start ]
equations
   [wxMaxima: subsect end   ] */


/* [wxMaxima: input   start ] */
eqx: x_Zug=x_GG+x_HR+x_Trag;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
eqy: y_GG=y_HR+y_Zug+y_Trag;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
Py_Trag: L_Trag^2=x_Trag^2+y_Trag^2;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
Py_Zug: L_Zug^2=x_Zug^2+y_Zug^2;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: subsect start ]
solving works
   [wxMaxima: subsect end   ] */


/* [wxMaxima: input   start ] */
res: dimensionally(solve([eqx, eqy, Py_Trag, Py_Zug], [x_Trag, y_Trag, x_Zug, y_Zug]))[1];
/* [wxMaxima: input   end   ] */


/* [wxMaxima: section start ]
but not the ones I need
   [wxMaxima: section end   ] */


/* [wxMaxima: subsect start ]
vars
   [wxMaxima: subsect end   ] */


/* [wxMaxima: input   start ] */
x_GG: 2`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
y_GG: 193`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_HR: 46`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_Trag: 50`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_Zug: 190`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
x_HR: 46*cos((149*%pi-360*acos(1/3))/360) ` mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
y_HR: 46*sin((149*%pi-360*acos(1/3))/360) ` mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: subsect start ]
equations
   [wxMaxima: subsect end   ] */


/* [wxMaxima: input   start ] */
eqx: x_Zug=x_GG+x_HR+x_Trag;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
eqy: y_GG=y_HR+y_Zug+y_Trag;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
Py_Trag: L_Trag^2=x_Trag^2+y_Trag^2;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
Py_Zug: L_Zug^2=x_Zug^2+y_Zug^2;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: subsect start ]
solving takes very long, but dosen't find a solution
   [wxMaxima: subsect end   ] */


/* [wxMaxima: input   start ] */
res: dimensionally(solve([eqx, eqy, Py_Trag, Py_Zug], [x_Trag, y_Trag, x_Zug, y_Zug])); float(%);
/* [wxMaxima: input   end   ] */



/* Old versions of Maxima abort on loading files that end in a comment. */
"Created with wxMaxima 21.02.0"$
4

1 回答 1

0

我尝试了一些不同的方法,有些方法比其他方法更好。最终起作用的是应用eliminate将四个方程减少到两个,然后再应用solve到那个。当然solve应该自己工作,它的缺点是它无法求解原始方程组。

这是我的脚本,您可以通过maxima --batch. 它找到的解决方案非常混乱,所以我想你必须决定它们是否真的有用。尝试使它更清洁的一件事是写,说,cos_asin_a不是cos(...)and sin(...)。然后你可以替换cos_asin_a解决后。

linel: 65 $
load(ezunits);
x_GG: 2`mm;
y_GG: 193`mm;
L_HR: 46`mm;
L_Trag: 50`mm;
L_Zug: 190`mm;
x_HR: 46*cos((149*%pi-360*acos(1/3))/360) ` mm;
y_HR: 46*sin((149*%pi-360*acos(1/3))/360) ` mm;
eqx: x_Zug=x_GG+x_HR+x_Trag;
eqy: y_GG=y_HR+y_Zug+y_Trag;
Py_Trag: L_Trag^2=x_Trag^2+y_Trag^2;
Py_Zug: L_Zug^2=x_Zug^2+y_Zug^2;

dimensionally (eliminate ([eqx, eqy, Py_Trag, Py_Zug], [x_Trag, x_Zug]));
solutions_y: dimensionally (solve (%, [y_Trag, y_Zug]));
grind (solutions_y);
solutions_y_numerical: float (solutions_y);
solutions_y_numerical_filtered: sublist (%, lambda ([e], every (lambda ([x], qty(x) > 0), map (rhs, e))));

dimensionally (eliminate ([eqx, eqy, Py_Trag, Py_Zug], [y_Trag, y_Zug]));
solutions_x: dimensionally (solve (%, [x_Trag, x_Zug]));
grind (solutions_x);
solutions_x_numerical: float (solutions_x);
solutions_x_numerical_filtered: sublist (%, lambda ([e], every (lambda ([x], qty(x) > 0), map (rhs, e))));

solutions_numerical_filtered: append (solutions_x_numerical_filtered[1], solutions_y_numerical_filtered[1]);
subst (%, [eqx, eqy, Py_Trag, Py_Zug]), numer;

问题设置和你的一样,新的东西是从头eliminate开始的。最后打印的数值解是

[x_Trag = 44.09785089359991 ` mm, 
x_Zug = 91.98740317879643 ` mm, 
y_Trag = 23.56649202927388 ` mm, 
y_Zug = 166.2477598538445 ` mm]

(我假设负量的解决方案是非物理的——我想你可以肯定地说。)

我也试过to_poly_solve了,它包含在 Maxima 中;它无法解出原始方程。

我正在使用千里马 5.44。我没有在任何早期版本上尝试过。

于 2021-05-17T06:59:26.923 回答