Answer

问题及解答

[Bug]

Posted by haifeng on 2023-03-24 23:06:25 last update 2023-03-28 20:25:44 | Edit | Answers (0)

>> :mode=polyn
Switch into polynomial mode.

>> (2x^2-x+3)==(3-x+x^2+x^2)

导致退出

原因找到了, accept_number_as_string() 函数中读取单项式前系数时会将 3-x 看作 x 的系数.


>>  (1|3x^1-1|9)*(3x^3+10x^2+2x-3)+( -5|9x^2-25|9x^1-10|3)
in> (1|3x^1-1|9)*(3x^3+10x^2+2x-3)+(-5|9x^2-25|9x^1-10|3)

out> |9*x^1-10
------------------------


>> :mode polyn
Switch into polynomial mode.

>>  (1|3x^1-1|9)*(3x^3+10x^2+2x-3)+( -5|9x^2-25|9x^1-10|3)
in> (1|3x^1-1|9)*(3x^3+10x^2+2x-3)+(-5|9x^2-25|9x^1-10|3)

out> x^4+10|3-1|3x^3+2|3-10|9-5|9x^2-2|9-25|9-1x^1+1|3-10|3
------------------------

 

(1|3x^1-1|9)*(3x^3+10x^2+2x-3)+( -5|9x^2-25|9x^1-10|3)

1|1x^4+3|1x^3-4|9x^2-11|9x^1+1|3-5|9x^2-25|9x^1-10|3

正确的结果是

\[
\begin{split}
&(\frac{1}{3}x-\frac{1}{9})\cdot (3x^3+10x^2+2x-3)+(-\frac{5}{9}x^2-\frac{25}{9}x-\frac{10}{3})\\
= &\frac{1}{9}(3x-1)\cdot(3x^3+10x^2+2x-3)+(-\frac{5}{9}x^2-\frac{25}{9}x-\frac{10}{3})\\
= &\frac{1}{9}(9x^4+30x^3+6x^2-9x-3x^3-10x^2-2x+3)+(-\frac{5}{9}x^2-\frac{25}{9}x-\frac{10}{3})\\
= &\frac{1}{9}(9x^4+27x^3-4x^2-11x+3)-\frac{1}{9}(5x^2+25x+30)\\
= &\frac{1}{9}(9x^4+27x^3-9x^2-36x-27)\\
= & x^4+3x^3-x^2-4x-3
\end{split}
\]