mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[apps/graph] When computing derivative function at abscissa, round the
result Change-Id: I23817dda6ff9fe335e819086ecad5119eba1d948
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user