[apps/graph] When computing derivative function at abscissa, round the

result

Change-Id: I23817dda6ff9fe335e819086ecad5119eba1d948
This commit is contained in:
Émilie Feral
2017-01-04 17:29:06 +01:00
parent 412cd7fb1e
commit be247b0392
2 changed files with 3 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#include "function.h"
#include <string.h>
#include <math.h>
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;
}