Commit Graph

583 Commits

Author SHA1 Message Date
Émilie Feral
24c9617a89 [poincare] Templatize TreeHandle Builders 2019-02-21 11:29:35 +01:00
Émilie Feral
7b5f3c570d [poincare] Change the way Expression are built 2019-02-21 11:29:35 +01:00
Émilie Feral
ac6f23684d [poincare] Clean Expression and Layout builders
Before: Opposite(Opposite(Rational(1))) misleadingly created the
expression "-1"; now, Opposite::Builder(Opposite::Builder(Rational(1)))
creates "--1"
2019-02-21 11:29:35 +01:00
Émilie Feral
13dbc3edb3 [poincare] Power: (a^b)^c -> a^(b*c) with a < 0 and c integer is not
always true when complex format is real:
R(-1)^2 is undefined
2019-02-15 16:40:38 +01:00
Émilie Feral
73bd40292a [poincare] Power: fix rule R(-x) --> i*R(x) is not true if x < 0 2019-02-15 16:40:38 +01:00
Émilie Feral
4dc513e5c5 [poincare] Power: fix (x+1)^0 reduction when the Reduction target is
System
2019-02-14 10:47:05 +01:00
Émilie Feral
3402721069 [poincare] Test: Add a parameter ReductionTarget (User or System) in
Helper::assert_parsed_expression_evaluates_to and
Helper::assert_parsed_expression_simplify_to
2019-02-14 10:47:05 +01:00
Émilie Feral
02b27124f4 [poincare] Integer: remove duplicate method: isInfinite is equivalent to
isOverflow
2019-02-05 16:42:36 +01:00
Émilie Feral
4f3bd12fea [poincare] Fix bug: undef*x--> undef 2019-02-05 16:42:24 +01:00
Émilie Feral
e9b11d5bf7 [poincare] Power: fix rule x^0 and 1^x with x infinity 2019-02-01 10:40:03 +01:00
Émilie Feral
8855390f91 [poincare] Logarithm: add rule on log(inf) 2019-02-01 10:40:03 +01:00
Émilie Feral
3226426a55 [poincare] Fix Logarithm with Infinite arguments 2019-02-01 10:40:03 +01:00
Émilie Feral
b58573bad3 [poincare] Multiplication: do not apply rule 0*x --> 0 if x involves an
infinite expression
2019-02-01 10:40:03 +01:00
Émilie Feral
fd2eb95ae7 [poincare] Fix tests on user variables 2019-01-22 14:57:38 +01:00
Émilie Feral
f8f4705929 [poincare] AbsoluteValue: fix shallowReduce to reduce abs(0) to 0 2019-01-21 13:40:17 +01:00
Léa Saviot
0bf3e678d9 [poincare] Add tests and asserts about sign, such as sign(0)==0 2019-01-21 11:22:55 +01:00
Léa Saviot
614cfe8306 [poincare] Add tests on SignFunction 2019-01-21 11:22:55 +01:00
Émilie Feral
a539b2f061 [poincare] Test: fix tests on Complex Format 2019-01-10 11:42:05 +01:00
Léa Saviot
4788495d62 [poincare/parser] -1/2 gives - 1/2 and not -(1) / 2 2019-01-10 11:42:05 +01:00
Émilie Feral
9709fb66b1 [poincare] When approximating, make a special case for x^(p/q) when the
complex format is real.

In this case, x^(p/q) might have a real result which is not the
principale angle returned by the standard library
2019-01-10 11:42:05 +01:00
Léa Saviot
b30c197d36 [test/poincare] Tests on expression order 2019-01-10 11:42:05 +01:00
Léa Saviot
e5f0959239 [poincare] Static Expression methods start with uppercase 2019-01-10 11:42:05 +01:00
Léa Saviot
4bfd77b093 [test] Replace assert by quiz_assert 2019-01-10 11:42:04 +01:00
Léa Saviot
b25c8f4df2 [poincare] Fix store tests 2019-01-10 11:42:04 +01:00
Léa Saviot
101db272c8 [test/calculation] 1+1->a shoud display 2, not 1+1=2 2019-01-10 11:42:04 +01:00
Émilie Feral
95248edde0 [poincare] Fix tests with new beautify order 2019-01-10 11:42:04 +01:00
Émilie Feral
b8826b1cf4 [poincare] (-1)^(p/q) is not reduced the same way according to the
complex format
2019-01-10 11:42:04 +01:00
Émilie Feral
ae2de436c2 [poincare] Add tests on ComplexFormat == Real 2019-01-10 11:42:04 +01:00
Émilie Feral
cbd3eeb3f6 [poincare] Turn i into unreal when complexFormat is Real 2019-01-10 11:42:04 +01:00
Émilie Feral
ecf3f2ea0f [poincare] Create a a flag on Expression that is set when the
approximation encouters a complex value

All approximation methods take the complex format into account.
2019-01-10 11:42:04 +01:00
Émilie Feral
26e2e9be0d [poincare] Add complex format as an argument of simplification 2019-01-10 11:42:04 +01:00
Émilie Feral
1f247b731d [poincare] Discard useless parameters of sign and isReal methods 2019-01-10 11:42:04 +01:00
Émilie Feral
f00f639bed [poincare] Interrupt simplification of when too many nodes where
generated while bubbling up ComplexCartesian. Retry with another
ReductionTarget
2019-01-10 11:42:03 +01:00
Émilie Feral
759aee2345 [poincare] Discard wrong optimization. NAryExpression children are
sorted but Power(ComplexCartesian) is after ComplexCartesian in the
simplification order. ComplexCartesian are not ensure to be last ones if
some children are not real.
2019-01-10 11:42:03 +01:00
Émilie Feral
df2f6e3b6e [poincare] Fix tests with complex cas 2019-01-10 11:42:03 +01:00
Émilie Feral
a02fd614ab [poincare] Trigonometry: add rule arctan(1/x) = sign(x)*pi/2-arctan(x) 2019-01-10 11:42:03 +01:00
Émilie Feral
5b782c3ff7 [poincare] Power: fix sqrt(-1*i) != i*sqrt(i) 2019-01-10 11:42:03 +01:00
Émilie Feral
2fe8b386c3 [poincare] Add tests on Complex 2019-01-10 11:42:03 +01:00
Émilie Feral
7d9c49919c [poincare] simplifyForComplexFormat: before extracting
ComplexCartesian/ComplexPolar, deepReduce instead of simplify to avoid
generating uselessly big trees. To make it work, implement shortcuts for
Power::complexCartesian and Power::complexPolar to return nice cartesian
expression when the power index is -1, 1/2 or -1/2
2019-01-10 11:42:03 +01:00
Émilie Feral
c62922ec5c [poincare] Change complex getters design: extract real and imaginary
parts at the same time in complexCartesian and norm and arg in
complexPolar
2019-01-10 11:42:03 +01:00
Émilie Feral
64aebcf16d [poincare] Implement shallowReduce of ComplexArgument, AbsoluteValue,
RealPart and ImaginaryPart
2019-01-10 11:42:03 +01:00
Émilie Feral
2f8ede54f2 [poincare] The sign function was used to decide wether an expression was
of form -x. However, ln(0.3) has a negative sign but is not of form -x.
This commit fixes the misuse of ExpressionNode::Sign::negative.
For example, we do not turn sin(tan(9)) in -sin(-tan(9)) or
arcsin(sin(12)) in -arcsin(-sin(12) because tan(9)<0 and sin(12)<0
2019-01-10 11:42:03 +01:00
Émilie Feral
9e2b709fcb [poincare] Change sign() signature to sign(context, angleUnit) 2019-01-10 11:42:03 +01:00
Émilie Feral
68367343ed [poincare] Add tests on complex extractors 2019-01-10 11:42:03 +01:00
Émilie Feral
d72b906919 [poincare] SquareRoot: implement realPart & imaginaryPart 2019-01-10 11:42:03 +01:00
Émilie Feral
ee0d158bd9 [poincare] Add rules on cos(arcsin), cos(arctan), sin(arccos),
sin(arctan), tan(arccos), tan(arcsin)
2019-01-10 11:42:03 +01:00
Émilie Feral
3c3f68c6c4 [poincare] Multiplication and Division implement realPart,
imaginaryPart and complexNorm
2019-01-10 11:42:03 +01:00
Émilie Feral
d95585956c [poincare] Implement Expression::realPart, Expression::imaginaryPart,
Expression::complexNorm, Expression::complexArgument
2019-01-10 11:42:03 +01:00
Émilie Feral
0e1825817b [poincare] Test: clean helper
Create a method expressions_are_equal
2019-01-10 11:42:02 +01:00
Émilie Feral
88a2751e6b [poincare] Add SignFunction class 2019-01-10 11:42:02 +01:00