Commit Graph

3943 Commits

Author SHA1 Message Date
Gabriel Ozouf
4209f0a26c [poincare/function] getVariables always gets the argument
When applied to a function f(x) = constant, the method getVariables
would not find any, as the search is performed on the function's
definition.
Thus, when using the "Fill with formula" tool in Statistics, if the
formula to fill V1 is "V1=f(V2)", the formula will be considered
constant and applied to all values in V1. However, if V1 is longer than
V2, the program will attempt to read undefined values of V2.
With this change, the formula will only be applied to lines in V1 for
which there is a corresponding line in V2.
2020-12-29 17:20:09 +01:00
Gabriel Ozouf
48d93584e7 [poincare/parametered_expression] Fix variables detection
The method getVariables would not correctly remove the parameter from
the list of variables.
e.g. In the expression "box+y×int(z,x,0,1)", when trying to remove x
from the list of variables, the letter x would be removed from the name
"box" instead.
2020-12-29 13:34:09 +01:00
Gabriel Ozouf
fff514d410 [poincare/unit] Fix temperature conversion
The program would crash when trying to evaluate a unit conversion of the
form "x→_U" where U was a unit of temperature and x did not have any
unit.
2020-12-29 09:51:47 +01:00
Hugo Saint-Vignes
e09bd0a18c [poincare] Factorize reduce and removeUnit methods 2020-12-22 17:32:40 +01:00
Hugo Saint-Vignes
7146eff7ee [poincare/src] Use reduce before removeUnit
With deepReduce(), when a simplifiaction was interrupted, expression could
contain Undefined children, which would trigger the assert in
removeUnit(). With reduce(), if a simplification is interrupted, the
entire expression becomes Undefined, which is handled by removeUnits().
2020-12-22 17:32:40 +01:00
Gabriel Ozouf
02d7a02a93 [poincare/unit] Add test 2020-12-22 17:21:37 +01:00
Gabriel Ozouf
9b3f7edfcd [poincare/unit] Handle kelvin with prefix
Units derived from kelvin (mK, cK, ...) were handled like Celsius and
Fahrenheit, causing a bug where multiplications such as 2*pi*_cK to
simplify as undef.
2020-12-22 17:21:37 +01:00
Gabriel Ozouf
efbbbe94ff [poincare/expression] Comment and variable names 2020-12-14 10:20:09 +01:00
Gabriel Ozouf
c7b758f536 [poincare/expression] Fix solutions to e^x=0
Because of the limitations of the floating-point representation, e^x is
null for x <= 710, causing the nextRoot functions to find roots for it.
To prevent this, we looking for places where a function changes sign, we
actually require the function to take two non-null values of different
signs.
2020-12-14 10:20:09 +01:00
Gabriel Ozouf
94b2da8e60 [poincare/zoom] Comment on the representation of ranges 2020-12-10 13:45:56 +01:00
Gabriel Ozouf
185c780215 [poincare/zoom] Handle NAN in ExpandSparseWindow 2020-12-10 13:45:56 +01:00
Gabriel Ozouf
35bfb8ec16 [poincare/zoom] Method ExpandSparseWindow
This method is used to remove extraneous empty sapce in the middle of
the window for functions that are discontinuous between their points of
interest.
2020-12-10 13:45:56 +01:00
Gabriel Ozouf
625a89e610 [poincare/zoom] RefinedYRangeForDisplay signature 2020-12-10 13:45:56 +01:00
Gabriel Ozouf
71070ee052 [poincare/zoom] Helper method SetZoom
Create a method SetZoom to zoom in and out on a window.
2020-12-10 13:45:56 +01:00
Émilie Feral
fe4e2e3e9d Misc. clang static analyzer fixes 2020-12-09 13:34:36 +01:00
Gabriel Ozouf
55f21f127c [poincare/zoom] Fix array overflow 2020-12-07 16:45:54 +01:00
Gabriel Ozouf
89979b4f50 [poincare/zoom] Comment on the RangeWithRatio method 2020-12-07 15:58:56 +01:00
Gabriel Ozouf
71be09b4e7 [poincare, graph] Factor helper function 2020-12-07 15:58:56 +01:00
Gabriel Ozouf
8726bbda3e [poincare/zoom] Update tests 2020-12-07 15:58:56 +01:00
Gabriel Ozouf
072fdda6b8 [poincare/zoom] Redraft search of orthonormal range
To find the optimal range with a specified ratio, we compute the values
of the function on a default range, then center the Y axis to display
the maximum number of points of the function.
2020-12-07 15:58:56 +01:00
Gabriel Ozouf
7f63daa28e [poincare/zoom] Change weight function in RangeWithRatioForDisplay
Change-Id: I21520d8220083b40baa2e4928632632f2b73cb9b
2020-12-07 15:58:56 +01:00
Gabriel Ozouf
bd302bb67b [poincare/unreal] Type in derivate method
Unreal's derivate method returns true, to signify that it is unchanged
by the derivation operation. This implementation mostly exists for
documentation, as an Unreal derivand will be handled by the
defaultShallowReduce method.
2020-12-07 15:01:52 +01:00
Gabriel Ozouf
7ae03975cc [poincare/derivative] Derivate special numbers
Derivate the numbers Undefined, Unreal, Infinity symbolically :
  Undefined -> Undefined
  Unreal    -> Unreal
  Infinity  -> Undefined
2020-12-07 15:01:52 +01:00
Gabriel Ozouf
3f6e4444a5 [poincare/derivative] Reduce before replacing symbol
The general formula for deriving a power makes use of the logarithm,
which often disappears at simplification. However, replacing the symbol
before simplifying can lead to applying an invalid argument to the
logarithm, making the whole expression invalid.

e.g. diff(1/x,x,-2)
     If x is replaced by -2 before reducing the power derivative, ln(-2)
will reduce to Unreal, as will the rest of the expression.
2020-12-07 14:06:24 +01:00
Gabriel Ozouf
1a47207bee [poincare/trigonometry] Add comments 2020-12-04 11:59:12 +01:00
Gabriel Ozouf
1f0a18f94c [poincare/derivative] Update tests for trigonometric derivatives 2020-12-04 11:59:12 +01:00
Gabriel Ozouf
a113801ec2 [poincare/derivative] Fix derivative of trigonometric functions
The classic differentiation forumals for trigonometric functions assume
a variable in radians. A multiplicative constant must be added when
another unit is used.

Change-Id: Iec428acd7d93e415fddb184300437ae09d1d997c
2020-12-04 11:59:12 +01:00
Gabriel Ozouf
64208a7f3c [poincare/trigonometry] Method UnitConversionFactor
Change-Id: I4ef3e4404071a305354b572e15e5199040f9bf48
2020-12-04 11:59:12 +01:00
Gabriel Ozouf
f329ca825f [poincare] Add ReductionContext to unaryFunctionDifferential
Change-Id: I99ba90f8c38cab5d8fe2139f49e4f94c1d52d296
2020-12-04 11:59:12 +01:00
Hugo Saint-Vignes
636e863323 [escher] Moved repetition factor logic up in Escher from poincare
Change-Id: I7c8f932e3e7d04c928ca881113ba6b5df05b94e7
2020-12-02 17:20:32 +01:00
Gabriel Ozouf
b69f06b772 [poincare/logarithm] Comment clarity 2020-12-02 16:54:09 +01:00
Gabriel Ozouf
1531f96bb8 [poincare/derivative] Update test on derivation 2020-12-02 16:54:09 +01:00
Gabriel Ozouf
764d14fed1 [poincare/constant] Constants differentiate to 0 2020-12-02 16:54:09 +01:00
Gabriel Ozouf
a178c88e54 [poincare/logarithm] Fix derivative domain of definition
The logarithm function is undefined for negative numbers, but its
derivative, the inverse function, is defined everywhere. We thus need to
virtually limit the domain of definition of the derivative.
2020-12-02 16:54:09 +01:00
Gabriel Ozouf
48bd7b6a77 [poincare/logarithm] Factor corner case log(x,0) and log(x,1) 2020-12-02 16:49:09 +01:00
Gabriel Ozouf
f09f06d7ac [poincare/logarithm] Update tests 2020-12-02 16:49:09 +01:00
Gabriel Ozouf
9775953142 [poincare/logarithm] ln(0) = undef
As a consequence, log(x,0) = ln(x)/ln(0) = undef
2020-12-02 16:49:09 +01:00
Gabriel Ozouf
2ba1941270 [poincare/zoom] Float litterals
Change-Id: Ifea5f356b9cee271c43b3d9b9168fd38db78d87a
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
ddfde60982 [poincare/zoom] Update tests for the device
Change-Id: Ied73829ff294dc243ca177c5c2acfb374a7446b9
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
746a781016 [poincare/zoom] Fix coding style
Change-Id: I263e1a95023f650376bf6a1c4bb45426d52d5e4c
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
fdcccde996 [poincare/zoom] Update unit tests
Change-Id: Ic108bfbacd54d43ef6c721589ada813ca648e88e
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
4869383263 [poincare/zoom] Better handling of single points of interest
Functions with a single point of inerest used to be drawn on a tiny
interval around this point.
Now, an orthonormal window is built around the point of interest, giving
a much nicer view.

Change-Id: I7793797aead2695532ddea44d93d62bb7ef870f4
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
229865aff8 [poincare/zoom] Rework unit tests
Change-Id: Id0ff36517d14710701f6a4c1cec8817442b6f946
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
291b400595 [poincare/zoom] Ignore imprecise float value
When looking for extrema in a function, we need to discard results where
the function growth rate is smaller than the precision of the float type
itself : these results are likely to be too noisy, and can cause false
positives.
e.g. : The sqrt(x^2+1)-x function

Change-Id: I6e2c002d7308b41a4c226d274cbb5d9efe4ea7db
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
adf28345b1 [poincare/zoom] Reduce zoom artifact
Do not use the bounds of the interval when computing a refined range.
As the bounds are often integers, the zoom would give strange result on
some non-continuous functions (e.g. f(x) = x!).

Change-Id: Ie127fe15191cb3951cff223adc8dc3172188c789
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
a418602763 [poincare/zoom] Remember points of interest when refining
Change-Id: I229cbffa2577d23bfa0a4c0632bc9ec32ae338e7
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
ca9cb63909 [poincare/zoom] Reduce the step for searching points of interest
The algorithm to search for points of interest will miss some. We reduce
the step to make it more precise, so that tan(x) and tan(x-90) have the
same profile.

Change-Id: Ia1bac1d4e7b98d2d6f36f8ce12ed9dac67d40198
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
540209f1a9 [poincare/zoom] Preserve standard bound when normalizing
Change-Id: I6d736e945eda6982ad26836763feded8a55134a0
2020-11-26 17:51:40 +01:00
Gabriel Ozouf
e4162976e4 [poincare/zoom] Method NextUnit
Change-Id: I8200c38fd44b662dcffa8e9850fc272f3e2dc7e8
2020-11-26 17:51:40 +01:00
Hugo Saint-Vignes
3ac3fba468 [poincare] Prevent system parenthesis text insertion
Change-Id: I5963d2fda37ed9776059b29edced75f88b4ccb2b
2020-11-20 13:33:00 +01:00