[apps/shared] CartesianFunction::approximateDerivative returns NAN out

of the function domain
This commit is contained in:
Émilie Feral
2019-09-09 11:15:57 +02:00
parent 111a789f51
commit 5be68133a1

View File

@@ -215,6 +215,9 @@ int CartesianFunction::printValue(double cursorT, double cursorX, double cursorY
}
double CartesianFunction::approximateDerivative(double x, Poincare::Context * context) const {
if (x < tMin() || x > tMax()) {
return NAN;
}
Poincare::Derivative derivative = Poincare::Derivative::Builder(expressionReduced(context).clone(), Symbol::Builder(UCodePointUnknownX), Poincare::Float<double>::Builder(x)); // derivative takes ownership of Poincare::Float<double>::Builder(x) and the clone of expression
/* TODO: when we approximate derivative, we might want to simplify the
* derivative here. However, we might want to do it once for all x (to avoid