Numworks Epsilon  1.4.1
Graphing Calculator Operating System
hyperbolic_cosine.cpp
Go to the documentation of this file.
2 #include <poincare/complex.h>
3 #include <poincare/addition.h>
4 #include <poincare/power.h>
5 #include <poincare/division.h>
6 #include <poincare/opposite.h>
8 extern "C" {
9 #include <assert.h>
10 }
11 #include <cmath>
12 
13 namespace Poincare {
14 
17 }
18 
21  return a;
22 }
23 
24 Expression * HyperbolicCosine::shallowReduce(Context& context, AngleUnit angleUnit) {
25  Expression * e = Expression::shallowReduce(context, angleUnit);
26  if (e != this) {
27  return e;
28  }
29 #if MATRIX_EXACT_REDUCING
30  Expression * op = editableOperand(0);
31  if (op->type() == Type::Matrix) {
32  return SimplificationEngine::map(this, context, angleUnit);
33  }
34 #endif
35  return this;
36 }
37 
38 template<typename T>
40  if (c.b() == 0) {
41  return Complex<T>::Float(std::cosh(c.a()));
42  }
44  Complex<T> exp1 = Power::compute(e, c);
45  Complex<T> exp2 = Power::compute(e, Complex<T>::Cartesian(-c.a(), -c.b()));
46  Complex<T> sum = Addition::compute(exp1, exp2);
47  return Division::compute(sum, Complex<T>::Float(2));
48 }
49 
50 }
friend class HyperbolicCosine
Definition: expression.h:49
Expression * clone() const override
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
Definition: addition.cpp:331
c(generic_all_nodes)
Expression * editableOperand(int i)
Definition: expression.h:176
#define M_E
Definition: math.h:12
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
Definition: division.cpp:52
const Expression * m_operands[T]
static Complex< T > Float(T x)
Definition: complex.cpp:23
Type type() const override
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
Definition: power.cpp:84
#define cosh(x)
Definition: math.h:173
static Complex< T > computeOnComplex(const Complex< T > c, AngleUnit angleUnit)