Overview Clamps Packages CM Dictionary Clamps Dictionary Fomus
Next: flash , Previous: find-sensor , Up: F , Home: Overview

Clamps Dictionary

fit-quadratic

Function

(fit-quadratic x1 y1 x2 y2 x3 y3)

Return a polynomial function of second order which fits through the 3 given points in the arguments.

Arguments

x1 Number denoting the x coordinate of the first point.
y1 Number denoting the y coordinate of the first point.
x2 Number denoting the x coordinate of the second point.
y2 Number denoting the y coordinate of the second point.
x3 Number denoting the x coordinate of the third point.
y3 Number denoting the y coordinate of the third point.

Example

(let ((fn (fit-quadratic 1 3 7 6.8 14 14)))
  (loop for x in '(1 7 14) collect (funcall fn x)))

; => (3.0 6.8 14.0)
fit-quadratic.svg
Figure 4: Plot of quadratic fit
(mplot
 (list
  (let* ((fn (fit-quadratic 1 3 7 6.8 14 14))
         (values (cons 0 (loop for x from 1 to 14 collect (funcall fn x)))))
    (mapcar #'list (integrate values) (mapcar #'dround (cdr values))))
  (let* ((fn (fit-quadratic 1 6.2 6 9.6 11 14))
         (values (cons 0 (loop for x from 1 to 11 collect (funcall fn x)))))
    (mapcar #'list (integrate values) (mapcar #'dround (cdr values)))))
 :xrange '(-5 100)
 :yrange '(-1 15)
 :lt :points)
desintegrations-plot.svg
Figure 5: Plot of Tristan Murail's example of Desintegrations

Author: Orm Finnendahl

Created: 2025-12-12 Fr 21:35

Validate