# Newton's Method Calculator for a System of two Equations

An interactive calculator using Newton's method [1] to approximate the solutions of a system of two equations in two variables is presented. It approximates the solutions, if there is any, and gives a table of all values of iterations for educational purposes.

## Newton's Method for Systems of Equations

Newton's method is numerical method used to find the roots of an equation by iterations starting from an approximate initial solution. When dealing with a system of equations, the method extends naturally by considering the Jacobian matrix and its determinant.

## One Variable Newton's Method

Suppose that we need to solve the following equation $f(x) = 0$ Taylor expansion of $$f(x+\Delta x)$$ is given by $f(x+\Delta x) \approx f(x) + \Delta x f'(x)$ We now solve $$f(x+\Delta x) = 0$$ which gives $f(x) + \Delta x f'(x) = 0$ which gives $\Delta x \approx - \dfrac{f(x)}{f'(x)}$ Suppose we know an approximate value $$x_n$$ of the root of the equation, the approximate root $$x_{n+1}$$ defined by $\Delta x = x_{n+1} - x_n$ is given by $x_{n+1} \approx x_{n} - \dfrac{f(x)}{f'(x)}$

## System of Equations and the Jacobian Matrix

Consider a system of two equations in two variables $$x$$ and $$y$$: \begin{align*} f(x, y) &= 0 \\ g(x, y) &= 0 \end{align*} The Jacobian matrix $$J$$ of the system is given by: $J = \begin{bmatrix} \frac{\partial f}{\partial x} & \frac{\partial f}{\partial y} \\ \frac{\partial g}{\partial x} & \frac{\partial g}{\partial y} \end{bmatrix}$

## Newton's Method Update

The update formulas for Newton's method for a system of equations are given by: \begin{aligned} \Delta x &= \frac{-f \cdot g_y + g \cdot f_y}{\text{D}} \\\\ \Delta y &= \frac{-g \cdot f_x + f \cdot g_x}{\text{D}} \end{aligned} hence \begin{aligned} x_{n+1} &\approx x_n + \frac{-f \cdot g_y + g \cdot f_y}{\text{D}} \\\\ y_{n+1} &\approx y_n + \frac{-g \cdot f_x + f \cdot g_x}{\text{D}} \end{aligned} Where $$f$$ and $$g$$ are the functions evaluated at the current $$(x_n, y_n)$$ values.
$$f_x, f_y, g_x, g_y$$ are the partial derivatives of $$f$$ and $$g$$ with respect to $$x$$ and $$y$$, respectively.
$$\text{D} = f_x \cdot g_y - f_y \cdot g_x$$ is the determinant of the Jacobian matrix.

## Iterative Process

Newton's method iteratively updates the variables $$x$$ and $$y$$ using the above formulas until a stopping criterion is met. The common stopping criteria include:
Convergence tolerance: Stop when the difference between consecutive iterations is below a certain threshold.
Maximum iterations: Stop after a maximum number of iterations is reached.
1. Initialization: Start with initial guesses for $$x$$ and $$y$$: One way to obtain close initial guesses for the solution to the system is to graph $$f(x,y)$$ and $$g(x,y)$$, approximate their points of interscetion use them as initial guesses.
2. Evaluate Functions and Derivatives: Compute $$f(x, y)$$, $$g(x, y)$$, and their partial derivatives at the current $$(x, y)$$ values.
3. Calculate Determinant: Compute the determinant of the Jacobian matrix.
4. Update Variables: Use the Newton's method update formulas to compute $$\Delta x$$ and $$\Delta y$$.
5. Iterate: Update $$x$$ and $$y$$ using $$\Delta x$$ and $$\Delta y$$, and repeat until convergence or maximum iterations are reached.
6. The tolerance $$\epsilon$$ is used to test the absolute value of $$f(x,y)$$ and $$g(x,y)$$ as follows:
When $$|f(x,y)| \lt \epsilon$$ and $$|g(x,y)| \lt \epsilon$$, the iteration process stops.
7. The calculator approximate one solution at the time.
Newton's method provides a robust and efficient way to approximate the solutions of a system of equations in two variables, given that the initial guesses are close enough to the actual solutions and the functions are differentiable in the neighborhood of the solutions.

## Results

Table including the iteration values of $$x, y, f(x,y)$$ and $$g(x,y)$$.
Iteration $$x$$ $$y$$ $$f(x, y)$$ $$g(x, y)$$