Main Content

基于问题求解多项式非线性方程组

x 是 2×2 矩阵时,方程

x3=[1234]

是多项式方程组。此处,x3 表示使用矩阵乘法的 x*x*x。您可以使用基于问题的方法轻松地构造和求解此方程组。

首先,将变量 x 定义为一个 2×2 矩阵变量。

x = optimvar('x',2,2);

使用 x 定义要求解的方程。

eqn = x^3 == [1 2;3 4];

用此方程创建一个方程问题。

prob = eqnproblem('Equations',eqn);

[1 1;1 1] 点开始求解问题。

x0.x = ones(2);
sol = solve(prob,x0)
Solving problem using fsolve.

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
sol = struct with fields:
    x: [2x2 double]

检查解。

disp(sol.x)
   -0.1291    0.8602
    1.2903    1.1612

显示解的立方。

sol.x^3
ans = 2×2

    1.0000    2.0000
    3.0000    4.0000

另请参阅

相关主题