Just when you though you had forgotten Mathics3
Table of Contents
This release starts to address some of the performance problems and
terminology confusion that goes back to the very beginning. As a result,
this release is not API compatible with prior releases.
In conjunction with the performance improvement in this release, we
start refactoring some of the core classes and modules to start to get
this to look and act more like other interpreters, and to follow more
current Python practice.
More work will continue in subsequent releases.
New Builtins
- Euler's
Beta
function. Bernoulli
.CatalanNumber
(Integer arguments only).CompositeQ
.Diagonal
. Issue #115.Divisible
.EllipticE
EllipticF
EllipticK
EllipticPi
EulerPhi
$Echo
. Issue #42.FindRoot
was improved for supporting numerical derivatives Issue
#67, as well as the use of scipy libraries when are available.FindRoot
(for thenewton
method) partially supports
EvaluationMonitor
andStepMonitor
options.FindMinimum
andFindMaximum
now have a minimal implementation
for 1D problems and the use of scipy libraries when are available.LogGamma
.ModularInverse
.NumericFunction
.Projection
.- Partial support for Graphics option
Opacity
. SeriesData
operations was improved.TraceEvaluation[]
shows expression name calls and return values of
it argument.- Pass option
ShowTimeBySteps
, to show accumulated time before
each step - The variable
$TraceEvalution
when set True will show all
expression evaluations.
- Pass option
TraditionalForm
Enhancements
D
acts overIntegrate
andNIntegrate
. Issue #130.SameQ
(===
) handles chaining, e.g.a == b == c
or
SameQ[a, b, c]
.Simplify
handles expressions of the formSimplify[0^a]
Issue
#167.Simplify
andFullSimplify
support optional parameters
Assumptions
andComplexityFunction
.UnsameQ
(=!=
) handles chaining, e.g.a =!= b =!= c
or
UnsameQ[a, b, c]
.- Assignments to usage messages associated with
Symbols
is allowed
as it is in WMA. With this and other changes, Combinatorica 2.0
works as written. Share[]
performs an explicit call to the Python garbage collection
and returns the amount of memory free.- Improve the compatibility of
TeXForm
andMathMLForm
outputs with
WMA. MathML tags around numbers appear as "<mn>" tags instead of
"<mtext>", except in the case ofInputForm
expressions. In
TeXForm some quotes around strings have been removed to conform to
WMA. It is not clear whether this is the correct behavior. - Allow
scipy
andskimage
to be optional. In particular: revise
Nintegrate[]
to useMethod="Internal"
when scipy isn't
available. - Pyston up to versions from 2.2 to 2.3.4 are supported as are PyPy
versions from 3.7-7.3.9.0 up 3.9-7.3.9. However those Python
interpreters may have limitations and limitations on packages that
they support. - Improved support for
Series
Issue #46. Cylinder
rendering is implemented in Asymptote.
Documentation
- "Testing Expressions" section added.
- "Representation of Numbers" section added.
- "Descriptive Statistics" section added and "Moments" folded into
that. - Many More URL references.
<url>
now supports link text. - Referecne Chapter and Sections are now in alphabetical order
- Two-column mode was removed in most sections so the printed PDF
looks nicer. - Printed Error message output in test examples is in typewriter font
and doesn't drop inter-word spaces.
Internals
- Inexplicably, what the rest of the world calls a "nodes" in a tree
or or in WMA "elements" in a tree had been called a "leaves". We
now use the proper term "element". - Lots of predefined
Symbol
s have been added. Many appear in the
modulemathics.core.systemsymbols
. - Attributes are now stored in a bitset instead of a tuple of string.
This speeds up attributes read, and RAM usage, . Symbol.is_numeric
andExpression.is_numeric
now uses the
attributeDefinition.is_numeric
to determine the returned value.NIntegrate
internal algorithms and interfaces toscipy
were
moved tomathics.algorithm.integrators
and
mathics.builtin.scipy_utils.integrators
respectively.N[Integrate[...]]
now is evaluated asNIntegrate[...]
- Definitions for symbols
CurrentContext
andContextPath[]
are
mirrored in themathics.core.definitions.Definitions
object for
faster access. FullForm[List[...]]
is shown as{...}
according to the WL
standard.Expression.is_numeric()
accepts anEvaluation
object as a
parameter; the definitions attribute of that is used.SameQ
first checks the type, then theid
, and then names in
symbols.- In
mathics.builtin.patterns.PatternTest
, if the condition is one
of the most used tests (NumberQ
,NumericQ
,StringQ
, etc) the
match
method is overwritten to specialized versions that avoid
function calls. mathics.core.patterns.AtomPattern
specializes the comparison
depending of theAtom
type.- To speed up development, you can set
NO_CYTHON
to skip Cythonizing
Python modules. If you are using Pyston or PyPy, Cythonization slows
things down. any
andall
calls were unrolled as loops in Cythonized modules:
this avoids the overhead of a function call replacing it by a (C)
for loop, which is faster.- A bug was fixed relating to the order in which
mathics.core.definitions
stores the rules InstanceableBuiltin
->BuiltinElement
BoxConstruction
->BoxExpression
- the method
Element.is_true()
was removed in favor of
is SymbolTrue
N[_,_,Method->method]
was reworked. Issue #137.- The methods
boxes_to_*
were moved toBoxExpression
. - remove
flatten_*
from theAtom
interface. Definition
has a new propertyis_numeric
.
Speed improvements:
- Creating two
Symbol
objects with the same name will give the same
object. This avoids unnecessary string comparisons, and calls to
ensure_context
. - Attributes are now stored in a bitset instead of a tuple of strings.
- The
Definitions
object has two properties:current_contex
and
context_path
. This speeds up the lookup of symbols names. These
properties store their values into the corresponding symbols in the
builtin
definitions. eval_N
was add to speed up the then often-used built-in function
N
.Expression
evaluation was gone over and improved. properties on
the collection which can speed up evaluation, such as whether an
expression is fully evaluated, is ordered, or is flat are collected.List
evaluation is customized. There is a newListExpression
class which has a more streamlinedevaluate()
method. More of this
kind of thing will followBaseExpression.get_head
avoids building a symbol saving two
function calls.
Package update
- SymPy 1.10.1
Compatibility
-
ScriptCommandLine
now returns, as the first element, the name of
the script file (when available), for compatibility with WMA. Issue
#132. -
Expression.numerify
improved in a way to obtain a behavior closer
to WMA. -
NumericQ
lhs expressions are now handled as a special case in assignment. For exampleNumericQ[a]=True
tells the interpreter thata
must be considered -
a numeric quantity, so
NumericQ[Sin[a]]
evaluates toTrue
.
Bugs
First
,Rest
andLast
now handle invalid arguments.Set*
: fixed issue #128.SameQ
: comparison with MachinePrecision only needs to be exact
within the last bit Issue #148.- Fix a bug in
Simplify
that produced expressions of the form
ConditionalExpression[_,{True}]
. - Fix bug in
Clear
andClearAll
(#194). - Fix base 10 formatting for infix
Times
. Issue #266. - Partial fix of
FillSimplify
- Streams used in MathicsOpen are now freed and their file descriptors
now released. Issue #326. - Some temporary files that were created are now removed from the
filesystem. Issue #309. - There were a number of small changes/fixes involving
NIntegrate
and its Method options.Nintegrate
tests have been expanded. - Fix a bug in handling arguments of pythonized expressions, that are
produced byCompile
when the llvmlite compiler fails. N
now handles arbitrary precision numbers when the number of
digits is not specified.- [N[Indeterminate]]{.title-ref} now produces
[Indeterminate]{.title-ref} instead a
[PrecisionReal(nan)]{.title-ref}. - Fix crash in
NestWhile
when supplyingAll
as the fourth
argument. - Fix the comparison between
Image
and other expressions. - Fix an issue that prevented that [Collect]{.title-ref} handles
properly polynomials on expressions (issue #285). - Fix a bug in formatting expressions of the form
(-1)^a
without the
parenthesis (issue #332). - Fix a but in failure in the order in which
mathics.core.definitions
stores the rules. - Numeric overflows now do not affect the full evaluation, but instead
just the element which produce it. - Compatibility with the way expressions are ordered more closely
follows WMA: Now expressions with fewer elements come first (issue
#458). - The order of the context name resolution (and
$ContextPath
) was
switched;"System
comes before"Global
.
Incompatible changes
The following changes were motivated by a need to speed up the
interpreter.
Expression
arguments differ. The first parameter has to be aSymbol
while the remaining arguments have to be some sort ofBaseElement
rather than something that can be convertedr to an element.
2 Properties for the collection of elements can be specified when they
are known. To get the old behavior, use to_expression
- Expressions which are lists are a new kind of class,
ListExpression
. As with expressions, the constructor requires
valid elements, not something convertible to an element. Use
to_mathics_list