Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

interpolate


Type:   -   Lisp function (closure)
Source:   -   xm.lsp

Syntax

(interpolate x x1 y1 x2 y2)
x, x1, y1, x2, y2 - integer or floating point numbers
returns - the 'y' value corresponding to 'x'

In Nyquist, 'interpolate' is implemented as a Lisp function:

(defun interpolate (x x1 y1 x2 y2)
  (cond ((= x1 x2) x1)
        (t (+ y1 (* (- x x1) (/ (- y2 y1) (- x2 (float x1))))))))

Description

The 'interpolate' function linearly interpolates [or extrapolates] between points (x1, y1) and (x2, y2) to compute the 'y' value corresponding to 'x'.

Examples


  Back to Top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference