Numworks Epsilon  1.4.1
Graphing Calculator Operating System
derivative.h
Go to the documentation of this file.
1 #ifndef POINCARE_DERIVATIVE_H
2 #define POINCARE_DERIVATIVE_H
3 
7 
8 namespace Poincare {
9 
10 class Derivative : public StaticHierarchy<2> {
12 public:
13  Type type() const override;
14  Expression * clone() const override;
15  int polynomialDegree(char symbolName) const override;
16 private:
17  /* Layout */
18  ExpressionLayout * privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const override {
19  return LayoutEngine::createPrefixLayout(this, floatDisplayMode, complexFormat, name());
20  }
21  int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
22  return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, name());
23  }
24  const char * name() const { return "diff"; }
25  /* Simplification */
26  Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
27  /* Evaluation */
28  Expression * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
29  Expression * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedApproximate<double>(context, angleUnit); }
30  template<typename T> Expression * templatedApproximate(Context& context, AngleUnit angleUnit) const;
31  template<typename T> T growthRateAroundAbscissa(T x, T h, VariableContext<T> variableContext, AngleUnit angleUnit) const;
32  template<typename T> T riddersApproximation(VariableContext<T> variableContext, AngleUnit angleUnit, T x, T h, T * error) const;
33  // TODO: Change coefficients?
34  constexpr static double k_maxErrorRateOnApproximation = 0.001;
35  constexpr static double k_minInitialRate = 0.01;
36  constexpr static double k_rateStepSize = 1.4;
37 };
38 
39 }
40 
41 #endif
#define T(x)
Definition: events.cpp:26
static ExpressionLayout * createPrefixLayout(const Expression *expression, PrintFloat::Mode floatDisplayMode, Expression::ComplexFormat complexFormat, const char *operatorName)
Type type() const override
Definition: derivative.cpp:14
Expression * clone() const override
Definition: derivative.cpp:18
static int writePrefixExpressionTextInBuffer(const Expression *expression, char *buffer, int bufferSize, int numberOfDigits, const char *operatorName)
int polynomialDegree(char symbolName) const override
Definition: derivative.cpp:23