Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/rreusser/complex-zeros-delves-lyness

[WIP] Compute the zeros of a complex analytic function using the method of Delves and Lyness
https://github.com/rreusser/complex-zeros-delves-lyness

Last synced: 2 months ago
JSON representation

[WIP] Compute the zeros of a complex analytic function using the method of Delves and Lyness

Awesome Lists containing this project

README

        

# complex-zeros-delves-lyness

> Compute the zeros of a complex analytic function using the method of Delves and Lyness

## Introduction

Given a complex analytic function and its derivative, this module uses [the method of Delves and Lyness](http://www.ams.org/mcom/1967-21-100/S0025-5718-1967-0228165-4/S0025-5718-1967-0228165-4.pdf) [[1]](#References) to compute the zeros. That is, it computes

s_N = \frac{1}{2 \pi i} \oint z^N \frac{f'(z)}{f(z)} dz

numerically using [adaptive Simpson's method](https://github.com/scijs/integrate-adaptive-simpson) integration. In the absence of poles, [Cauchy's argument principle](https://en.wikipedia.org/wiki/Argument_principle) states s0 is the number of zeros M. Using [Newton's Identities](https://en.wikipedia.org/wiki/Newton%27s_identities), the moments s1 through sM are transformed into a polynomial, the roots of which correspond to the encircled zeros of the function f and which may be computed with a complex polynomial root-finder like the [Weierstrass](http://github.com/scijs/durand-kerner) method.

## To Do
Currently locates multiple zeros with recursive subdivision, but needs checks for near-zero along the contour and check for poor S0 integration. Optional derivative-based post-processing refinement (i.e. Newton-Raphson) would also be a nice plus.

## Installation

Can be installed from github, but not currently published.

## Example

The single zero of the function cos(z) + sin(z) inside the unit circle is z0 = -π / 4:

```javascript
var zeros = require('complex-zeros-delves-lyness');

function f (out, a, b) {
out[0] = Math.cosh(b) * (Math.cos(a) + Math.sin(a));
out[1] = Math.sinh(b) * (Math.cos(a) - Math.sin(a));
};

function fp (out, a, b) {
out[0] = Math.cosh(b) * (Math.cos(a) - Math.sin(a));
out[1] = -Math.sinh(b) * (Math.cos(a) + Math.sin(a));
};

zeros(f, fp, [0, 0], 1);
// => [ [ -0.785398350762156 ], [ 3.289335470668675e-11 ] ]
```

Since f and f' are used 1-1 and often repeat many identical operations, they may be computed together and returned as the third and fourth entries of the output array:

```javascript
function f (out, a, b) {
var chb = Math.cosh(b);
var shb = Math.sinh(b);
var ca = Math.cos(a);
var sa = Math.sin(a);
out[0] = chb * (ca + sa);
out[1] = shb * (ca - sa);
out[2] = chb * (ca - sa);
out[3] = -shb * (ca + sa);
};

zeros(f, null, [0, 0], 1);
// => [ [ -0.785398350762156 ], [ 3.289335470668675e-11 ] ]
```

## Usage

#### `require('complex-zeros-delves-lyness')(f, fp, z0, r, tol, maxDepth)`

Compute the zeros of a complex analytic function.

**Arguments**:
- `f: function(out: Array, a: Number, b: Number)`: a function that places the real and imaginary components of f(a + ib) into the first and second elements of the output array.
- `fp: function(out: Array, a: Number, b: Number)`: a function that places the real and imaginary components of f'(a + ib) into the first and second elements of the output array. If `fp` is `null`, argument `f` may instead place the real and imaginary components of f' into the third and fourth elements of the output of `f`.
- `z0: Array`: an `Array` specifying the real and imaginary components of the center of the contour around which to integrate. Default is `[0, 0]`.
- `r: Number`: the radius of the contour. Default is `1`.
- `tol`: tolerance used in the integration and polynomial root-finding steps. Default is `1e-8`.
- `maxDepth`: maximum recursion depth of the adaptive Simpson integration. Default is `20`.

**Returns**:
Returns `false` on failure, otherwise an array containing an `Array` containing `Arrays` of the real and imaginary components of the zeros, respectively. That is, 1 + 2i and 3 + 4i would be returned as `[[1, 3], [2, 4]]`.

## References
[1] Delves, L. M., & Lyness, J. N. (1967). [A numerical method for locating the zeros of an analytic function](http://www.ams.org/mcom/1967-21-100/S0025-5718-1967-0228165-4/S0025-5718-1967-0228165-4.pdf). Mathematics of Computation.

## License

© 2016 Ricky Reusser. MIT License.

[npm-image]: https://badge.fury.io/js/complex-zeros-delves-lyness.svg
[npm-url]: https://npmjs.org/package/complex-zeros-delves-lyness
[travis-image]: https://travis-ci.org/rreusser/complex-zeros-delves-lyness.svg?branch=master
[travis-url]: https://travis-ci.org//complex-zeros-delves-lyness
[daviddm-image]: https://david-dm.org/rreusser/complex-zeros-delves-lyness.svg?theme=shields.io
[daviddm-url]: https://david-dm.org//complex-zeros-delves-lyness