ApasScript.

Numerical Methods

nroot

A numerical root of an expression in a bracket where it changes sign (Brent's method). Returns a record: x, residual, the final bracket (lower, upper), iterations, evaluations and status.

rk4

Solves y' = f(t, y) with fixed-step classical Runge-Kutta (RK4). Returns a record with the final t and y, iterations, evaluations and status.

bisection

A root by bisection in a bracket where the function changes sign. Slow but always keeps the root bracketed.

newton

A root by Newton's method from a starting guess. Needs the derivative; not guaranteed to converge.

secant

A root by the secant method from two starting guesses; not guaranteed to converge.

nderiv

A numerical derivative by central differences with Richardson extrapolation, with an error estimate.

nderivForward

A numerical derivative by forward differences with Richardson extrapolation.

nintegrate

A numerical definite integral by adaptive Simpson's rule, with an error estimate.

trapezoid

The composite trapezoid rule with n panels (refined once to estimate the error).

simpson

The composite Simpson rule with n panels (n even; refined once to estimate the error).

lerp

Linear interpolation: the value at x on the line through (x0, y0) and (x1, y1).

euler

Solves y' = f(t, y) with fixed-step Euler steps.

rk45

Solves y' = f(t, y) up to a target t with adaptive Runge-Kutta-Fehlberg 4(5) steps.

nminimize

The minimum of a function on an interval by Brent's method (the function should have one minimum there).

goldenMin

The minimum of a function on an interval by golden-section search.

fitLine

The least-squares line y = intercept + slope*x through data points, with the residual sum of squares.

newton2

Newton's method for two equations f1 = 0, f2 = 0 in two variables, from a starting point; the Jacobian is exact (symbolic).

fitOneParameter

The parameter value in [lower, upper] that minimizes an objective (e.g. a sum of squared errors).

newtonInterp

The interpolating polynomial through the points (xs, ys), in Newton's divided-difference form, evaluated at x.

spline

The natural cubic spline through the points (xs, ys), evaluated at x.

fft

The discrete Fourier transform of a list whose length is a power of 2 (real or complex).

ifft

The inverse discrete Fourier transform.