Main Content

Solve Nonlinear System of Polynomials, Problem-Based

When x is a 2-by-2 matrix, the equation


is a system of polynomial equations. Here, x3 means x*x*x using matrix multiplication. You can easily formulate and solve this system using the problem-based approach.

First, define the variable x as a 2-by-2 matrix variable.

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

Define the equation to be solved in terms of x.

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

Create an equation problem with this equation.

prob = eqnproblem('Equations',eqn);

Solve the problem starting from the point [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]

Examine the solution.

   -0.1291    0.8602
    1.2903    1.1612

Display the cube of the solution.

ans = 2×2

    1.0000    2.0000
    3.0000    4.0000

See Also

Related Topics