Commit Graph

1372 Commits

Author SHA1 Message Date
É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
c3ad0e027c [poincare] Create class Unreal 2019-01-10 11:42:04 +01:00
Émilie Feral
5e434a4c33 [poincare] Get rid of useless arguments in shallowReduce 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
8bc1a7be05 [poincare] Preferences: add a ComplexFormat::Real 2019-01-10 11:42:04 +01:00
Émilie Feral
c0424089f7 [poincare] Clean Power 2019-01-10 11:42:03 +01:00
Émilie Feral
5e79949ba7 [poincare] Clean Trigonometry 2019-01-10 11:42:03 +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
1671ee8ec8 [poincare] Fix Undefined:: isReal is false 2019-01-10 11:42:03 +01:00
Émilie Feral
c4758873d2 [poincare] ComplexCartesian: when computing the squareNorm, simplify
cos^2+sin^2
2019-01-10 11:42:03 +01:00
Émilie Feral
9401edfd3f [poincare] Clean outdated comment 2019-01-10 11:42:03 +01:00
Émilie Feral
ff77b46276 [poincare] Power::shallowReduce. Fix bug: I complex should always be
shallowReduced as it turns into ComplexCartesian(0,1) if the reduction
target is the User and stays Constant(I) otherwise.
2019-01-10 11:42:03 +01:00
Émilie Feral
c6039423a9 [poincare] When simplifying an expression, also compute the approximation from the reduced
expression to avoid loss of precision.

If an expression is reduced to a ComplexCartesian(a, b), we compute the
approximation from ComplexCartesian(a,b) instead of going through the
potentially complicated expression resulting from beautifying
(sqrt(a^2+b^2)*exp(i*(arctan(b/a) -Pi/2*sign(b)) for example)
2019-01-10 11:42:03 +01:00
Émilie Feral
dae5c4d2d4 [poincare] Constant: i->ComplexCartesian(0,1) only if the reduction
target is the user
2019-01-10 11:42:03 +01:00
Émilie Feral
38de794642 [poincare] Change signature setSign(Context, AngleUnit, ReductionTarget) 2019-01-10 11:42:03 +01:00
Émilie Feral
8a00aa16cc [poincare] Clean: remove complexCartesian and complexPolar methods 2019-01-10 11:42:03 +01:00
Émilie Feral
cbd4f44539 [poincare] SignFunction: improve shallowReduce: sign(-x) = -sign(x) 2019-01-10 11:42:03 +01:00
Émilie Feral
383ac004cf [poincare] Take into account complex format in simplify 2019-01-10 11:42:03 +01:00
Émilie Feral
a6ac075442 [poincare] Fix Expression::CreateComplexExpression 2019-01-10 11:42:03 +01:00
Émilie Feral
cbef3dadb9 [poincare] Implement real and shallowReduce of ComplexCartesian on nodes: conjugate, function, symbol 2019-01-10 11:42:03 +01:00
Émilie Feral
3292bdfd44 [poincare] Sketch of complex reduction as part of the reduce routine 2019-01-10 11:42:03 +01:00
Émilie Feral
f714699575 [poincare] Clean Expression::CreateComplexExpression 2019-01-10 11:42:03 +01:00
Émilie Feral
9efc9e02e6 [poincare] Revert simplifyForComplexFormat 2019-01-10 11:42:03 +01:00
Émilie Feral
2e89f8b7de [poincare] Expression::simplifyForComplexFormat: Use a shortcut if the expression approximation is a real pure 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
f8251a74bc [poincare] SquareRoot: use realPart and imaginaryPart to compute the
complexArgument
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
5dae60bc7e [poincare] Complex parts getters (realPart, imaginaryPart,
complexNorm...) simplify while building the complex part
2019-01-10 11:42:03 +01:00
Émilie Feral
56c8e8b704 [poincare] Expression: create method ParseAndSimplifyForComplexFormat 2019-01-10 11:42:03 +01:00
Émilie Feral
f452d8fced [poincare] Fatorize code of Complex::complexToExpression in
Expression::CreateComplexExpression that create the expression a+i*b or
r*e^(i*th) from 2 expressions representing a & b or r & th.
2019-01-10 11:42:03 +01:00
Émilie Feral
476a79565f [poincare] Number::setSign does not need a context or angleUnit 2019-01-10 11:42:03 +01:00
Émilie Feral
fe6a5af47b [poincare] Change Expression::setSign signature 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
0c1e76c9c5 [poincare] Expression: add methods to get complex parts of expression 2019-01-10 11:42:02 +01:00
Émilie Feral
f8f3652687 [poincare] Expression: add radianToDegree and degreeToRadian methods 2019-01-10 11:42:02 +01:00
Émilie Feral
88a2751e6b [poincare] Add SignFunction class 2019-01-10 11:42:02 +01:00
Émilie Feral
c4ce3c28e1 [poincare] Factorial::sign is always positive 2019-01-10 11:42:02 +01:00
Léa Saviot
8c6ffa6d42 [apps] Fix graph X axis labels that read the same
Scenario: just zoom in in a graph
Fix:
- Do not truncate labels.
- Label size is computed depending on available size and number of
 labels.
- If labels cannot be displayed properly, just display the minimal
and maximal labels!
2019-01-10 11:42:02 +01:00
Léa Saviot
f62249c8ac [poincare] Try to reduce the number of digits in print float
We did not take into account the zeros ending the mantissa when
computing a smaller required length.
2019-01-10 11:42:02 +01:00
Léa Saviot
78c277b159 Fix comment typo 2019-01-10 11:42:02 +01:00
Léa Saviot
f470a99081 [poincare] Multiplications are collapsed in fractions
For instance, typing 3*2 the '/' creates the fraction (3*2)/
Before, it would only divide the '2'
2019-01-10 11:42:02 +01:00
Léa Saviot
f6a5759a16 [poincare] Fix the replacement of unknowns in the storage
In the Graph app, define f(x) = cos(x) and g(x)=diff(f(x),x,x).
The graph and table are perfectly computed, but in the Calculation apps,
g(5) fails.
2018-12-19 09:40:37 +01:00
Émilie Feral
ec08f027c0 [poincare] Revert: Use Simplify instead of Reduce II
To approximate an expression, it is more precise to
approximate its simplified form than its reduced form. Indeed, we want
to minimize the number of nodes in the expression before approximating.
For instance, a/b has fewer nodes than a*b^-1.
2018-12-18 10:46:20 +01:00