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)
(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)