Files
Upsilon/apps/graph/cartesian_function.cpp
Émilie Feral 2c06727f36 [apps] Simplify expressions in sequence and function applications
Change-Id: I2708934d3b5c90e8692e50d939b3a13028b8615e
2017-11-24 14:39:06 +01:00

34 lines
972 B
C++

#include "cartesian_function.h"
namespace Graph {
CartesianFunction::CartesianFunction(const char * text, KDColor color) :
Shared::Function(text, color),
m_displayDerivative(false)
{
}
bool CartesianFunction::displayDerivative() {
return m_displayDerivative;
}
void CartesianFunction::setDisplayDerivative(bool display) {
m_displayDerivative = display;
}
double CartesianFunction::approximateDerivative(double x, Poincare::Context * context) const {
Poincare::Complex<double> abscissa = Poincare::Complex<double>::Float(x);
Poincare::Expression * args[2] = {expression(context), &abscissa};
Poincare::Derivative derivative(args, true);
/* TODO: when we will simplify derivative, we might want to simplify the
* derivative here. However, we might want to do it once for all x (to avoid
* lagging in the derivative table. */
return derivative.approximateToScalar<double>(*context);
}
char CartesianFunction::symbol() const {
return 'x';
}
}