mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 14:20:39 +01:00
[apps/graph] Add method to approximate the derivative function at a
given abscissa Change-Id: I31bbd99a0469f7fad140a38dae1783b2d2ee414d
This commit is contained in:
@@ -61,9 +61,16 @@ void Function::setActive(bool active) {
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
float Function::evaluateAtAbscissa(float x, EvaluateContext * context) {
|
||||
float Function::evaluateAtAbscissa(float x, EvaluateContext * context) const {
|
||||
context->setOverridenValueForSymbolX(x);
|
||||
return m_expression->approximate(*context);
|
||||
}
|
||||
|
||||
float Function::approximateDerivative(float x, EvaluateContext * context) const {
|
||||
float functionPlus = evaluateAtAbscissa(x + k_epsilon, context);
|
||||
float functionMinus = evaluateAtAbscissa(x - k_epsilon, context);
|
||||
float growthRate = (functionPlus - functionMinus)/(2*k_epsilon);
|
||||
return growthRate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user