Computers play a crucial role in performing mathematical calculations that are an essential part of many applications, including:
Scientific Researchsolve complex equations and simulations of physical phenomena |
Financial Analysisfinancial modeling and risk analysis |
Gaming and Entertainmentphysics simulations, graphics rendering, and animation |
Transportationtraffic modeling, route optimization, and vehicle design. |
Marketing and Advertisingdata analysis and customer profiling |
Sportsanalyze motion, biomechanics, and performance data |
Computers perform many different algorithms, called numerical methods, to solve mathematical equations. The Newton-Raphson Method is one such algorithm that is used to solve equations.
Before diving in, let's first refresh our memory by starting with a basic, linear equation:
Ordinarily, we can solve it two ways. Check them out below.
To solve algebraically, we isolate x using basic addition, subtraction, multiplication or division.
$$ \begin{align}x+1 &= 0 \\ x + 1 - 1 &= -1 \\ x &= -1\end{align} $$
When an equation can be solved for an exact solution just by using these basic operations, we say that it can be solved analytically.
Computers can solve all linear equations analytically. However, as equations get more complicated, we'll find many that cannot be solved this way.
To solve graphically, we can plot the equation as a line on a graph. The solution is where the line intersects the x-axis.
Click on the correct ● solution below.
| x | y |
|---|---|
| -2 | -1 |
| -1 | 0 |
| 0 | 1 |
| 1 | 2 |
| 2 | 3 |
While computers do not solve basic linear equations graphically, they do use graph properties to solve more complex equations - especially ones that cannot be solved analytically!
Since graphs will help us solve more complex equations, let's get some practice!
Build your own equation and try to estimate the solution based on the graph!
\( y = \)
1
\( x^3 + \)
1
\( x^2 + \)
1
\(x + \)
1
Try approximating a solution based on the graph:
The easiest way to check is to substitute it back into the equation and see if we get zero!
1
·
\(^3 + \)
1
·
\(^2 + \)
1
·
\( + \)
1
=
While we can use our eyes to estimate the x-intercept point for this small range, computers will need a more algorithmic way to find it. They use something called tangents.
A tangent is a straight line that touches a curve at a single point. Since computers can easily handle straight lines, tangents allow computers to process more complicated curves.
Click the ● below for the tangent line at that point.
What do you notice about the tangent lines as you get closer to the x-intersect solution?
We can see that as you move along the curve, where the tangent line crosses the x-axis also gets closer and closer to the solution. We'll use this property in an algorithm called the Newton-Raphson method.
For the Newton-Raphson method, we strategically draw a series of tangent lines until we get to an approximation that's close enough to the solution. Let's try it with the below graph of \(y=x^2-2 \). (Scroll to zoom)
| Step 1: Make a guess for the solution. | Click ● to guess x = 2. |
Click ● to guess x = 1.5. |
Click ● to guess x = 1.417. |
| Step 2: Find the actual point where this is on the graph and draw its tangent line. | Click ● to draw the tangent | ||
| Step 3: Find where the tangent intercepts the x-axis. Check if this is a solution. | x=1.5 | x=1.417 | x=1.414 |
| Step 4: If not yet a solution, use this as the next guess and repeat steps 1-3. | (y=0.25) ❌ | (y ≈ 0.01) ❌ | (y ≈ 0.00) ✓ |
And that's it! We reached the solution! Let's try a couple more times on the next page.
Click on an equation to try it:
| Step 1: Make a guess for the solution. | Click ● to guess x = 6. |
Click ● to guess x = 9.5. |
Click ● to guess x = 8.645. |
| Step 2: Find the actual point where this is on the graph and draw its tangent line. | Click ● to draw the tangent | ||
| Step 3: Find where the tangent intercepts the x-axis. Check if this is a solution. | x=9.5 | x=8.645 | x=8.613 |
| Step 4: If not yet a solution, use this as the next guess and repeat steps 1-3. | (y ≈ -0.49) ❌ | (y ≈ 0.02) ❌ | (y ≈ 0.00) ✓ |
| Step 1: Make a guess for the solution. | Click ● to guess x = 1. |
Click ● to guess x = 0.891. |
| Step 2: Find the actual point where this is on the graph and draw its tangent line. | Click ● to draw the tangent | |
| Step 3: Find where the tangent intercepts the x-axis. Check if this is a solution. | x=0.891 | x=0.877 |
| Step 4: If not yet a solution, use this as the next guess and repeat steps 1-3. | (y ≈ -0.02) ❌ | (y ≈ 0.00) ✓ |
| Step 1: Make a guess for the solution. | Click ● to guess x = 1. |
Click ● to guess x = -2. |
Click ● to guess x = 4. |
| Step 2: Find the actual point where this is on the graph and draw its tangent line. | Click ● to draw the tangent | ||
| Step 3: Find where the tangent intercepts the x-axis. Check if this is a solution. | x=-2 | x=4 | x=-8 |
| Step 4: If not yet a solution, use this as the next guess and repeat steps 1-3. | (y ≈ -1.26) ❌ | (y ≈ 1.59) ❌ | (y = -2) ❌ |
Would you like to see the mathematical formula for the Newton-Raphson method going on behind the scenes?
| n | Calculation | \(x_n\) |
|---|---|---|
| 0 | 2 | |
| 1 | \( x_{1} = x_{0} - \frac{f(x_0)}{f'(x_0)} = 2 - \frac{f(2)}{f'(2)} = 2 - \frac{2}{4} \) | 1.5 |
| 2 | \( x_{2} = x_{1} - \frac{f(x_1)}{f'(x_1)} = 1.5 - \frac{f(1.5)}{f'(1.5)} = 1.5 - \frac{0.25}{3} \) | 1.417 |
| 3 | \( x_{3} = x_{2} - \frac{f(x_2)}{f'(x_2)} = 1.417 - \frac{f(1.417)}{f'(1.417)} = 1.417 - \frac{0.01}{2.83} \) | 1.414 |
The Newton-Raphson Method is one of numerous numerical methods computers use. Some applications of this method include:
Finding the difference between a ML model's predicted and actual target output.


Estimating implied volatility to price options
Detect edges in images
