Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fgittins/muller

Python implementation of Muller's method for root finding.
https://github.com/fgittins/muller

Last synced: about 2 months ago
JSON representation

Python implementation of Muller's method for root finding.

Awesome Lists containing this project

README

        

# muller
Python implementation of Muller's method for root finding.

## Usage
`muller` has no dependencies.

Here is a quick example to show how it is used. First, import the root finder
```
from muller import muller
```
We will look for a root of
$$f(x) = e^{-x} \sin(x).$$
This has zeros at $x = n \pi$ with $n$ an integer.

We will look for the root at $x = 0$. We need three initial guesses for the root and will use $x = -1, 0, 1$. So,
```
from math import exp, sin

def f(x): return exp(-x)*sin(x)

xguesses = (-1, 0, 1)
```
To search for the root, we type
```
res = muller(f, xguesses)
```
We may examine the `res` object. The most useful attribute is `res.root`, which contains the estimate of the root.

## Testing
To test, run
```
python -m unittest tests.test
```
in the root directory.