diff --git a/apps/graph/function.cpp b/apps/graph/function.cpp index a69a0beda..3ef3aaf8f 100644 --- a/apps/graph/function.cpp +++ b/apps/graph/function.cpp @@ -1,5 +1,6 @@ #include "function.h" #include +#include namespace Graph { @@ -85,6 +86,7 @@ float Function::approximateDerivative(float x, Context * context) const { float functionPlus = evaluateAtAbscissa(x + k_epsilon, context); float functionMinus = evaluateAtAbscissa(x - k_epsilon, context); float growthRate = (functionPlus - functionMinus)/(2*k_epsilon); + growthRate = roundf(growthRate/k_precision)*k_precision; return growthRate; } diff --git a/apps/graph/function.h b/apps/graph/function.h index d55778d2d..26884032e 100644 --- a/apps/graph/function.h +++ b/apps/graph/function.h @@ -27,6 +27,7 @@ public: float approximateDerivative(float x, Context * context) const; private: constexpr static float k_epsilon = 0.0001f; + constexpr static float k_precision = 0.01f; constexpr static int k_bodyLength = 255; char m_text[k_bodyLength]; const char * m_name;