You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-43Lines changed: 38 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,11 @@ However, if you write the idiomatically correct form:
29
29
30
30
then _x_ will be a _Number_ with value __exactly__ one half.
31
31
32
+
Even better is to use the lazy expression mechanism:
33
+
34
+
val half: Expression = One / 2
35
+
half.materialize
36
+
32
37
You probably want to see some code: so go to the _worksheets_ package and take a look, starting with
33
38
NumberWorksheet.sc, Foucault1.sc, Newton.sc, and so on.
34
39
@@ -55,27 +60,11 @@ These allow the exact representation of roots, logarithmic numbers, radians, and
55
60
56
61
Current Version
57
62
---------------
58
-
The current version is 1.2.5. Here's a summary of what's new since 1.2.1:
59
-
60
-
* The entire _ExpressionMatchers_ code base has been rewritten (leaving many deprecated methods which need to be cleaned
61
-
up):
62
-
* The key method for simplifying _Expression_s is _simplify_. This operates recursively by invoking _matchSimpler_
63
-
until it encounters a miss, in which case it returns the previous simplified version. There are four phases of
64
-
simplification for a _CompositeExpression_:
65
-
*_simplifyComponents_
66
-
*_simplifyTrivial_
67
-
*_simplifyConstant_
68
-
*_simplifyComposite_
69
-
*_Algebraic_ quantities have been introduced:
70
-
* These represent solutions to equations that cannot be represented precisely with one quantity
71
-
*_Quadratic_ equations, for example, we can represent the Golden ratio $\phi$ exactly this way.
72
-
*_Linear_ equations (these solutions can already be represented, but this is just for completeness)
73
-
* The _NthRoot_ (renamed from _Root_) domain has been restructured to be more general.
74
-
* In addition to _SquareRoot_ and _CubeRoot_ (which were renamed from the ambiguous _Root2_ and _Root3_), there are
75
-
more general roots based on a rational inverse power.
76
-
* This _README.md_ file has been improved (including a logo, thanks to Zijie).
77
-
* Added Series and PowerSeries
78
-
* Fixed CircleCI issues
63
+
The current version is 1.2.10. Here's a summary of what's new since 1.2.5:
64
+
* A major restructuring where we effectively replaced _ReducedQuadraticRoot_ with _Root_ but where _Root_ is an _Expression_. In order for this to work, we renamed the old _Root_ (a subtype of _Factor_) as _NthRoot_.
65
+
* Another subtype of Expression was introduced: _Transcendental_. These are subtypes of AtomicExpression but rather than have a literal value, they define a value and an _ExpressionMonoFunction_ to be applied to that value.
66
+
* The _Log_ function is now dyadic and, in a parallel change, the old (natural) _log_ method has been renamed _ln_, allowing for new dyadic _log_ method.
67
+
* Additional tests have been introduced, including tests for _Root_ and _Transcendental_, while many other tests have been fixed. The only ignored tests are those that CircleCI objects to.
79
68
80
69
Sources
81
70
-------
@@ -91,6 +80,12 @@ You can also find the 7th printing free online:
The most important operators are those defined in _Expression.ExpressionOps_.
87
+
That's because you should normally be using the (lazy) expressions mechanism for arithmetic expressions.
88
+
These are the usual operators, except that the power operator is ∧ (not ^ or **).
94
89
95
90
Java API
96
91
========
@@ -189,7 +184,7 @@ It's probably the simplest just to include:
189
184
import Rational._
190
185
191
186
_Doubles_ are where the trickiest conversions apply.
192
-
Writing something like _Number(3.1415927)_ will result in a _FuzzyNumber_ with error bounds of 5 * 10^-7.
187
+
Writing something like _Number(3.1415927)_ will result in a _FuzzyNumber_ with error bounds of 5 * 10∧-7.
193
188
To be consistent with the _String_ representation, _Number(1.25)_ will result in an _ExactNumber_ represented internally
194
189
by a _Rational_ of 5/4.
195
190
However, if you want to force a number like 3.1415927 to be exact, then you will need to write
@@ -278,7 +273,7 @@ to build a _Mill_.
278
273
279
274
Some of the operators of _Mill_ are as follows:
280
275
281
-
^: Power
276
+
∧: Power (also ^)
282
277
+: Add
283
278
-: Subtract
284
279
*: Multiply (also ×)
@@ -406,7 +401,7 @@ Factor represents the domain in which a numerical quantity exists.
406
401
We are most familiar with the pure-number domain, including all the counting numbers,
407
402
the decimal numbers, and the so-called "real" numbers.
408
403
409
-
Slightly less familiar are numbers like $2\pi$ (we call the domain of such numbers "radians"), $\log_e 2$, $e^2$, and $√2$.
404
+
Slightly less familiar are numbers like $2\pi$ (we call the domain of such numbers "radians"), $\log_e 2$, $e∧2$, and $√2$.
410
405
All these numbers can be represented exactly by judicious use of the following classes.
411
406
412
407
The hierarchy of _Factor_ is as follows:
@@ -429,7 +424,7 @@ The inverse power (which root) is a _Rational_ in the case of _InversePower_ but
429
424
430
425
These allow certain quantities to be expressed exactly, for example, $sin(\frac{\pi}{3})$ is the square root of $\frac{3}{4}$.
431
426
The true (_Scalar_) values of the logarithmic numbers are
432
-
$e^x$, $2^x$, and $10^x$ respectively, where $x$ is the "value" of the _Number_.
427
+
$e∧x$, $2∧x$, and $10∧x$ respectively, where $x$ is the "value" of the _Number_.
433
428
434
429
Trigonometrical functions are designed to work with _Radian_ quantities.
435
430
Such values are limited (modulated) to be in the range $-\pi...\pi$.
@@ -443,9 +438,9 @@ Similarly, if you use the _atan_ method on a _Scalar_ number, the result will be
443
438
444
439
The 𝜀 factor works quite differently.
445
440
It is not a simple matter of scaling.
446
-
A _Number_ of the form _Number(x, NatLog)_ actually evaluates to $e^x$ rather than $e x$.
441
+
A _Number_ of the form _Number(x, NatLog)_ actually evaluates to $e∧x$ rather than $e x$.
447
442
448
-
It would be possible to implement $\pi$ values similarly to 𝜀 values (as evaluations of $e^{ix}$).
443
+
It would be possible to implement $\pi$ values similarly to 𝜀 values (as evaluations of $e∧{ix}$).
449
444
However, this is not currently done (future enhancement?).
450
445
See Complex numbers.
451
446
@@ -530,16 +525,16 @@ proportional to exactly 7.
530
525
531
526
It's important to realize that, to get the benefit of this behavior, you must use the _Expression_ mechanism (not a pure _Number_).
532
527
533
-
it should "give precise result for sqrt(7)^2" in {
528
+
it should "give precise result for sqrt(7)∧2" in {
534
529
val x: Expression = Number(7)
535
530
val y = x.sqrt
536
-
val z = y ^ 2
531
+
val z = y ∧ 2
537
532
z.materialize shouldBe Number(7)
538
533
}
539
-
it should "show ^2 and sqrt for illustrative purposes" in {
534
+
it should "show ∧2 and sqrt for illustrative purposes" in {
540
535
val seven = Number(7)
541
536
val x = seven.sqrt
542
-
val y = x power 2
537
+
val y = x ∧ 2
543
538
y shouldEqual Number(7)
544
539
y shouldBe Number(7)
545
540
}
@@ -580,13 +575,12 @@ The _hierarchy_ of Context is as follows:
580
575
581
576
Transcendental Numbers
582
577
======================
583
-
Apart from the special cases of $\pi$ and e, there is no way currently to store
584
-
transcendental numbers.
585
-
For numbers such as natural log of 2, we can express this lazily through an _Expression_.
586
-
A transcendental is based on an expression which can be evaluated.
587
-
Other transcendentals that are not based on an expression, are specified
588
-
simply as constants, for example, $\gamma$, the Euler-Mascheroni constant.
589
-
See the _Introduction.sc_ worksheet for examples.
578
+
Transcendental numbers are declared as subtypes of _Transcendental_, although $\pi$ and e are, additionally, declared as _Number_, _Real_, and _Expression_.
579
+
A transcendental is declared as a (named) _Expression_, where the expression might simply be a constant.
580
+
For example, L2 is defined as the natural log of 2 and has a name: "ln(2)".
581
+
Another example is $\gamma$, the Euler-Mascheroni constant.
582
+
See the _Introduction.sc_ worksheet for examples of usage.
583
+
The current list of transcendental numbers includes: $\pi$, e, $\gamma$, _ln(2)_, _lg(e)_, where _lg_ represents log to the base 2.
590
584
591
585
Error Bounds (Fuzziness)
592
586
========================
@@ -640,7 +634,7 @@ is given by slightly different expressions depending on whether the PDFs are ind
640
634
See the code (_Fuzz_) for details.
641
635
642
636
Things get only slightly more complex when applying monadic (single operand) functions or applying a function such
643
-
as $z=x^y$:
637
+
as $z=x∧y$:
644
638
645
639
In general, when we apply a monadic operator $y=f(x)$ (such as constant factor, as above, or power, or one of the trigonometric operators),
646
640
the formula for the relative fuzz of the result $\frac{Δy}{y}$ based on the relative fuzz of the input $\frac{Δx}{x}$ is:
@@ -708,8 +702,8 @@ Note that the type hierarchy is very likely to change in version 1.3
708
702
*_NumberLike_ (trait)
709
703
*_Numerical_ (trait: most numeric quantities)
710
704
*_Field_ (trait: something like the mathematical concept of a field)
711
-
*_Real_ (case class: a real number based on one _Number_)
712
-
*_Multivariate_ (trait which really should be called Algebraic)
705
+
*_Real_ (case class: a "real" number based on one _Number_)
706
+
*_Multivariate_ (trait: perhaps should be called "Algebraic")
713
707
*_Complex_ (trait: a complex number)
714
708
*_BaseComplex_ (abstract class)
715
709
*_ComplexCartesian_ (case class: Cartesian form of complex number)
@@ -820,6 +814,7 @@ Other types (for reference):
820
814
821
815
Versions
822
816
========
817
+
* Version 1.2.10: Another housekeeping release.
823
818
* Version 1.2.9: Mostly minor details that missed the previous version.
824
819
* Version 1.2.8: Major restructuring: renamed old _Root_ as _NthRoot_ and introduced new _Root_ which effectively replaced _ReducedQuadraticRoot_.
825
820
* Version 1.2.7: Introduced dyadic _Log_ functions and, in general, renamed (natural) _log_ method as _ln_, allowing for new dyadic _log_ method.
@@ -881,7 +876,7 @@ To begin, the hierarchy should look like this:
881
876
*_Transcendental_ (as now but extends _Expression_)
882
877
*_Field_ (as now, but with _Solution_ and _Series_ included)
883
878
*_Real_ (as now a single _Number_)
884
-
*_BranchedField_ (similar to _Multivariate_ in that there are multiple solutions or branches--these are the solutions to _Algebraic_s)
879
+
*_Multivariate_ (similar to _Multivalued_ in that there are multiple solutions or branches--these are the solutions to _Algebraic_s)
885
880
*_Complex_ (as now with two _Number_ fields--real and imaginary--conceivably, we might merge _Complex_ and _Solution_ and insist that the imaginary aspect of a _Number_ is represented in the _Number_ itself)
0 commit comments