%% Solve Nonlinear System of Polynomials, Problem-Based
% When x is a 2-by-2 matrix, the equation
% x^3 =\left\lbrack \begin{array}{cc}
% 1 & 2\\
% 3 & 4
% \end{array}\right\rbrack
% is a system of polynomial equations. Here, x^3 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)

% Examine the solution.

disp(sol.x)

% Display the cube of the solution.

sol.x^3

% Copyright 2019 The MathWorks, Inc.