Created
November 17, 2019 08:08
-
-
Save khusamov/203a754c8b8550afe9bb1a6a50437960 to your computer and use it in GitHub Desktop.
Кусочно-квадратичная интерполяция
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Кусочно-квадратичная интерполяция | |
// http://aco.ifmo.ru/el_books/numerical_methods/lectures/glava3.html | |
// | |
function interpol2(x, p) { | |
var a21 = (p[2][1] - p[0][1]) / ((p[2][0] - p[0][0]) * (p[2][0] - p[1][0])); | |
var a22 = (p[1][1] - p[0][1]) / ((p[1][0] - p[0][0]) * (p[2][0] - p[1][0])); | |
var a2 = a21 - a22; | |
var a1 = (p[1][1] - p[0][1]) / (p[1][0] - p[0][0]) - a2 * (p[1][0] + p[0][0]); | |
var a0 = p[0][1] - a1 * p[0][0] - a2 * Math.pow(p[0][0], 2); | |
return a0 + a1 * x + a2 * Math.pow(x, 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment