49 if (lookup !=
nullptr) {
62 newOp->shallowReduce(context, angleUnit);
64 return e->shallowReduce(context, angleUnit);
68 return e->
replaceWith(m,
true)->shallowReduce(context, angleUnit);
73 int unaryCoefficient = 1;
84 unaryCoefficient *= -1;
92 unaryCoefficient *= -1;
94 Expression * simplifiedCosine = e->shallowReduce(context, angleUnit);
96 return simplifiedCosine->
replaceWith(m,
true)->shallowReduce(context, angleUnit);
116 if (approxOp > 1.0f || approxOp < -1.0f) {
133 if (trigoOp >= -pi/2.0f && trigoOp <= pi/2.0f) {
138 if (lookup !=
nullptr) {
146 newOp->shallowReduce(context, angleUnit);
149 op->shallowReduce(context, angleUnit);
155 return e->
replaceWith(s,
true)->shallowReduce(context, angleUnit);
159 return e->
replaceWith(m,
true)->shallowReduce(context, angleUnit);
168 {{
"-90",
"\x89*(-2)^(-1)",
"",
"-1",
"undef"},
169 {
"-75",
"\x89*(-5)*12^(-1)",
"",
"(-1)*6^(1/2)*4^(-1)-2^(1/2)*4^(-1)",
"-(3^(1/2)+2)"},
170 {
"-72",
"\x89*2*(-5)^(-1)",
"",
"-(5/8+5^(1/2)/8)^(1/2)",
"-(5+2*5^(1/2))^(1/2)"},
171 {
"-135/2",
"\x89*(-3)*8^(-1)",
"",
"-(2+2^(1/2))^(1/2)*2^(-1)",
"-1-2^(1/2)"},
172 {
"-60",
"\x89*(-3)^(-1)",
"",
"-3^(1/2)*2^(-1)",
"-3^(1/2)"},
173 {
"-54",
"\x89*(-3)*10^(-1)",
"",
"4^(-1)*(-1-5^(1/2))",
"-(1+2*5^(-1/2))^(1/2)"},
174 {
"-45",
"\x89*(-4)^(-1)",
"",
"(-1)*(2^(-1/2))",
"-1"},
175 {
"-36",
"\x89*(-5)^(-1)",
"",
"-(5/8-5^(1/2)/8)^(1/2)",
"-(5-2*5^(1/2))^(1/2)"},
176 {
"-30",
"\x89*(-6)^(-1)",
"",
"-0.5",
"-3^(-1/2)"},
177 {
"-45/2",
"\x89*(-8)^(-1)",
"",
"(2-2^(1/2))^(1/2)*(-2)^(-1)",
"1-2^(1/2)"},
178 {
"-18",
"\x89*(-10)^(-1)",
"",
"4^(-1)*(1-5^(1/2))",
"-(1-2*5^(-1/2))^(1/2)"},
179 {
"-15",
"\x89*(-12)^(-1)",
"",
"-6^(1/2)*4^(-1)+2^(1/2)*4^(-1)",
"3^(1/2)-2"},
180 {
"0",
"0",
"1",
"0",
"0"},
181 {
"15",
"\x89*12^(-1)",
"6^(1/2)*4^(-1)+2^(1/2)*4^(-1)",
"6^(1/2)*4^(-1)+2^(1/2)*(-4)^(-1)",
"-(3^(1/2)-2)"},
182 {
"18",
"\x89*10^(-1)",
"(5/8+5^(1/2)/8)^(1/2)",
"4^(-1)*(5^(1/2)-1)",
"(1-2*5^(-1/2))^(1/2)"},
183 {
"45/2",
"\x89*8^(-1)",
"(2+2^(1/2))^(1/2)*2^(-1)",
"(2-2^(1/2))^(1/2)*2^(-1)",
"2^(1/2)-1"},
184 {
"30",
"\x89*6^(-1)",
"3^(1/2)*2^(-1)",
"0.5",
"3^(-1/2)"},
185 {
"36",
"\x89*5^(-1)",
"(5^(1/2)+1)*4^(-1)",
"(5/8-5^(1/2)/8)^(1/2)",
"(5-2*5^(1/2))^(1/2)"},
186 {
"45",
"\x89*4^(-1)",
"2^(-1/2)",
"2^(-1/2)",
"1"},
187 {
"54",
"\x89*3*10^(-1)",
"(5/8-5^(1/2)/8)^(1/2)",
"4^(-1)*(5^(1/2)+1)",
"(1+2*5^(-1/2))^(1/2)"},
188 {
"60",
"\x89*3^(-1)",
"0.5",
"3^(1/2)*2^(-1)",
"3^(1/2)"},
189 {
"135/2",
"\x89*3*8^(-1)",
"(2-2^(1/2))^(1/2)*2^(-1)",
"(2+2^(1/2))^(1/2)*2^(-1)",
"1+2^(1/2)"},
190 {
"72",
"\x89*2*5^(-1)",
"(5^(1/2)-1)*4^(-1)",
"(5/8+5^(1/2)/8)^(1/2)",
"(5+2*5^(1/2))^(1/2)"},
191 {
"75",
"\x89*5*12^(-1)",
"6^(1/2)*4^(-1)+2^(1/2)*(-4)^(-1)",
"6^(1/2)*4^(-1)+2^(1/2)*4^(-1)",
"3^(1/2)+2"},
192 {
"90",
"\x89*2^(-1)",
"0",
"1",
"undef"},
193 {
"105",
"\x89*7*12^(-1)",
"-6^(1/2)*4^(-1)+2^(1/2)*4^(-1)",
"",
""},
194 {
"108",
"\x89*3*5^(-1)",
"(1-5^(1/2))*4^(-1)",
"",
""},
195 {
"225/2",
"\x89*5*8^(-1)",
"(2-2^(1/2))^(1/2)*(-2)^(-1)",
"",
""},
196 {
"120",
"\x89*2*3^(-1)",
"-0.5",
"",
""},
197 {
"126",
"\x89*7*10^(-1)",
"-(5*8^(-1)-5^(1/2)*8^(-1))^(1/2)",
"",
""},
198 {
"135",
"\x89*3*4^(-1)",
"(-1)*(2^(-1/2))",
"",
""},
199 {
"144",
"\x89*4*5^(-1)",
"(-5^(1/2)-1)*4^(-1)",
"",
""},
200 {
"150",
"\x89*5*6^(-1)",
"-3^(1/2)*2^(-1)",
"",
""},
201 {
"315/2",
"\x89*7*8^(-1)",
"-(2+2^(1/2))^(1/2)*2^(-1)",
"",
""},
202 {
"162",
"\x89*9*10^(-1)",
"-(5*8^(-1)+5^(1/2)*8^(-1))^(1/2)",
"",
""},
203 {
"165",
"\x89*11*12^(-1)",
"(-1)*6^(1/2)*4^(-1)-2^(1/2)*4^(-1)",
"",
""},
204 {
"180",
"\x89",
"-1",
"0",
"0"}};
225 if (input ==
nullptr) {
228 Expression::Reduce(&input, context, angleUnit);
233 if (output ==
nullptr) {
236 Expression::Reduce(&output, context, angleUnit);
static float characteristicXRange(const Expression *e, Context &context, Expression::AngleUnit angleUnit)
static Preferences * sharedPreferences()
constexpr const char * cheatTable[Trigonometry::k_numberOfEntries][5]
Expression * replaceWith(Expression *newOperand, bool deleteAfterReplace=true)
Expression::AngleUnit angleUnit() const
virtual Expression * clone() const =0
const Integer denominator() const
static Expression * parse(char const *string)
bool isLowerThan(const Integer &other) const
Sign sign() const override
Expression * editableOperand(int i)
virtual int numberOfOperands() const =0
bool isIdenticalTo(const Expression *e) const
static Integer Addition(const Integer &i, const Integer &j)
static bool ExpressionIsEquivalentToTangent(const Expression *e)
const Integer numerator() const
static Expression * shallowReduceDirectFunction(Expression *e, Context &context, Expression::AngleUnit angleUnit)
static Complex< T > Float(T x)
static Integer Subtraction(const Integer &i, const Integer &j)
virtual float characteristicXRange(Context &context, AngleUnit angleUnit=AngleUnit::Default) const
static constexpr int k_numberOfEntries
virtual Sign sign() const
constexpr Event Multiplication
static Expression * table(const Expression *e, Expression::Type type, Context &context, Expression::AngleUnit angleUnit)
static Expression * shallowReduceInverseFunction(Expression *e, Context &context, Expression::AngleUnit angleUnit)
T approximateToScalar(Context &context, AngleUnit angleUnit=AngleUnit::Default) const
static Integer Multiplication(const Integer &i, const Integer &j)
const Expression * operand(int i) const
static IntegerDivision Division(const Integer &numerator, const Integer &denominator)
virtual int polynomialDegree(char symbolName) const
virtual Type type() const =0
void replaceOperand(const Expression *oldOperand, Expression *newOperand, bool deleteOldOperand=true)