Newton’s Method implemented in Rust.

applied.math.coding
4 min readOct 13, 2022

In this short story I want to provide a Rust implementation of Newton’s method for finding roots of functions. Newton’s method can be generalized to some extend but for real valued functions with one argument it looks like so:

Let f be a real-valued function f on some interval and f' denote its derivative. Then the following iteration is the Newton schema:

x_{n+1} = x_n - f(x_n) / f'(x_{n})

This sequence under certain conditions can be shown to converge against a root r of f, that is, f(r) = 0. One of the main criteria that ensures convergence is to have chosen x_0 close enough to r. More details about the theory behind this method can be found here.

Let us focus now on the implementation in Rust. Although, to just implement the iteration is straightforward, we will see the Rust provides some nice features to have it applicable as general as possible.

For everyone who needs a wrap-up in Rust, be invited to this little introduction.

Implementation:

--

--

applied.math.coding

I am a Software Developer - Java, Rust, SQL, TypeScript - with strong interest doing research in pure and applied Mathematics.