compute method
Returns the y
value of the y = f(x)
equation where the function f
is
built by interpolating the given nodes nodes and x
is the given point
at which the function has to be evaluated.
Implementation
@override
double compute(double x) {
var result = 0.0;
for (var i = 0; i < nodes.length; ++i) {
var term = nodes[i].y;
for (var j = 0; j < nodes.length; j++) {
if (i != j) {
term *= (x - nodes[j].x) / (nodes[i].x - nodes[j].x);
}
}
result += term;
}
return result;
}