在matlab中求解符号方程

时间:2014-07-11 10:40:09

标签: matlab symbolic-math equation-solving

我正在尝试解决形式

的符号方程式
D = lamda^12/339288145381785600000 + lamda^10/18124366740480000 +
    lamda^8/7846046208000 + lamda^6/523908000 + lamda^4/25200

其中lamda被声明为sym。我得到的输出不是可读的形式。即使vpa也没有以可读的形式给出答案。什么可以解决方案?

1 个答案:

答案 0 :(得分:2)

首先我们定义符号函数:

syms x
f(x) = x^12/339288145381785600000 + x^10/18124366740480000 + ...
    x^8/7846046208000 + x^6/523908000 + x^4/25200;
ezplot(f)

equation function_plot

接下来我们找到根(通过数字解决)。您也可以使用vpasolve MATLAB函数:

sol = feval(symengine, 'numeric::solve', f==0, x)

有1个真正的解决方案和8个复杂的解决方案:

>> sol(:)
sol =
   79.624598247213536847657202795915 - 49.037140566365604310129811798328*i
   79.624598247213536847657202795915 + 49.037140566365604310129811798328*i
                                       118.88396448746822093664197370373*i
                                      -118.88396448746822093664197370373*i
                                      -111.61305465738189638915837157361*i
                                       111.61305465738189638915837157361*i
                                                                         0
 - 79.624598247213536847657202795915 - 49.037140566365604310129811798328*i
 - 79.624598247213536847657202795915 + 49.037140566365604310129811798328*i

最后我们绘制了根源:

s = double(sol);
plot(real(s), imag(s), 'r.', 'MarkerSize',25)
axis square; axis([-100 100 -150 150]); box on
line(xlim(), [0 0], 'Color','k', 'LineStyle',':')
line([0 0], ylim(), 'Color','k', 'LineStyle',':')
xlabel('Re(x)'), ylabel('Im(x)'), title('Roots in Complex Plane')

roots_complex_plane