computeQuadratic function
Computes Y from a given X and function formula and returns it as a double for quadratic functions.
Implementation
double computeQuadratic(String formula, double value) {
double result = 0;
if (astParser(formula) == 'QUADRATIC_FUNCTION') {
double constant = irParser(formula)[0];
double factorToBeSquared = irParser(formula)[1];
double factorToBeMultiplied = irParser(formula)[2];
result = constant +
(factorToBeSquared * pow(value, 2)) +
(factorToBeMultiplied * value);
} else {}
return result;
}