Skip to main content

Section 10.1 Systems of nonlinear equations

Consider a non-linear system of more than one equation, such as

\begin{equation} \begin{cases} x^2e^{3y}-30 \amp = 0 \\ xy-\sin(x+y^2) \amp =0 \end{cases} \label{eq-nonlinear-system}\tag{10.1.1} \end{equation}

What method could we use to solve it numerically?

  • Bisection method does not apply. If we try to imitate it by taking a rectangle in the xy-plane and dividing it into 4 equal subrectangles, it is not clear which rectangle should be kept and why. The issue is that Intermediate Value Theorem, on which this method is based, does not generalize to systems.
  • Fixed point iteration still makes sense: we can rewrite the system as
    \begin{equation*} \begin{cases} x \amp = g(x, y) \\ y \amp = h(x, y) \end{cases} \end{equation*}
    and start iteration from some point \((x_0, y_0)\text{:}\) that is, \(x_1= g(x_0, y_0)\text{,}\) \(y_1 = h(x_0, y_0)\) and so on. If the process converges, we have a solution of the original system. But since there are more directions in which points can move under iteration, convergence is less likely than it was in one dimension.
  • Newton's method, which is essentially a systematic approach to fixed-point iteration, still works. This is the method we will use in this section.
  • It is not clear whether secant method makes sense, but its general idea - modifying Newton's method to avoid the use of derivatives - can be carried out. This will be considered later.

For notational convenience, we express a nonlinear system of \(n\) equations with \(n\) unknowns as a vector equation \(\mathbf F(\mathbf x)=0\) where \(\mathbf x\) is an unknown vector with \(n\) components. For example, to express (10.1.1) in vector form we write

\begin{equation} \mathbf x = \begin{pmatrix} x \\ y \end{pmatrix},\quad \mathbf F(\mathbf x) = \begin{pmatrix} x_1^2e^{3x_2}-30 \\ x_1 x_2 - \sin(x_1 + x_2^2) \end{pmatrix}\label{eq-function-F}\tag{10.1.2} \end{equation}

How should we write a vector function \(\mathbf F\) in Matlab? It can be an anonymous function.

F = @(x) [x(1)^2*exp(3*x(2)) - 30; x(1)*x(2) - sin(x(1) + x(2)^2)];
x = [3; -2];
disp(F(x))

In this example, the argument of F is a vector and the value it returns is also a vector. Note that F(3, -2) would result in an error “too many input arguments” because F takes only one argument (which is a vector). It needs to be F([3; -2]). Writing the input as a row vector, F([3, -2]) would have the same effect but for consistency with the formulas below it is better to use column vectors.

When the notation x(1), x(2) becomes too cumbersome, one can consider writing F as a named function, where the input vector is first unpacked into separate variables such as x, y. This makes the formula more readable. The downside is the restriction on named functions in Matlab, noted in Section 5.2.

function v = F(u)
    x = u(1);
    y = u(2);
    v = [x^2*exp(3*y) - 30; x*y - sin(x + y^2)];
end