scijs/complex-deriv-fornberg

Name: complex-deriv-fornberg

Owner: scijs

Description: Compute the derivative of a complex analytic function using the method of Fornberg

Created: 2016-06-05 19:50:06.0

Updated: 2018-04-04 10:36:53.0

Pushed: 2016-06-28 19:22:48.0

Homepage: null

Size: 22

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

complex-deriv-fornberg

Build Status npm version Dependency Status js-semistandard-style

Compute the derivative of a complex analytic function using the method of Fornberg

Introduction

This module uses the method of Fornberg to compute the derivatives of a complex analytic function along with error bounds. The method uses a Fourier Transform to invert function evaluations around a circle into Taylor series coefficients, uses Richardson Extrapolation to improve and bound the estimate, then multiplies by a factorial to compute the derivatives. Unlike real-valued finite differences, the method searches for a desirable radius and so is reasonably insensitive to the initial radius?to within a number of orders of magnitude at least. For most cases, the default configuration is likely to succeed.

Restrictions

The method uses the coefficients themselves to control the truncation error, so the error will not be properly bounded for functions like low-order polynomials whose Taylor series coefficients are nearly zero. If the error cannot be bounded, degenerate flag will be set to true, and an answer will still be computed and returned but should be used with caution.

Example

To compute the first five derivatives of 1 / (1 - z) at z = 0:

deriv = require('complex-deriv-fornberg');

tion f(a, b) {
r c = b * b + (1 - a) * (1 - a);
turn [(1 - a) / c, b / c];


v(f, 5, 0, 0)

>
 [ 1.0000000000000138,
  1.0000000000000107,
  2.0000000000000178,
  6.000000000000274,
  23.99999999999432,
  120.00000000001907 ],
[ 3.260944019499375e-17,
  -7.34322880255595e-17,
  -1.0399525753674522e-15,
  -1.9409005869118293e-14,
  -1.3097221675086528e-13,
  7.683410164000554e-13 ] ]

To output additional information about the computation, provide an empty object as the status argument:

status = {};

v(f, 5, 0, 0, {}, status)

tatus => 
 truncationError: 
 [ 3.1039630025864036e-13,
   3.1039375685463187e-13,
   6.207858181065558e-13,
   1.8624780843579008e-12,
   7.446002762584479e-12,
   3.726089802919438e-11 ],
roundingError: 
 [ 1.776399993410336e-15,
   6.560675025011761e-15,
   4.846032081004469e-14,
   5.369270732187135e-13,
   7.932006423296532e-12,
   1.464740954531565e-10 ],
degenerate: false,
iterations: 7,
finalRadius: 0.27076482018055015,
ailed: false }
Installation
m install complex-deriv-fornberg
API
require('complex-deriv-fornberg')([output, ]f, n, a, b[, options[, status]])

Compute the derivative of a complex analytic function f at a + b * i.

Parameters:

Returns: Returns the real and imaginary components of the derivatives in arrays, i.e. [[re1, re2, ...], [im1, im2, ...]], also writing the arrays to output, if provided.

Known Issues
References

[1] Fornberg, B. (1981). Numerical Differentiation of Analytic Functions. ACM Transactions on Mathematical Software (TOMS), 7(4), 512?526. http://doi.org/10.1145/355972.355979

License

© 2016 Scijs Authors. MIT License.

Authors

Ricky Reusser


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.