Release Notes for 1.11 - sympy/sympy GitHub Wiki
These are the release notes for SymPy 1.11. You can also find release notes for previous versions.
SymPy 1.11 was released on 23rd August 2022.
This version of SymPy has been tested on Python 3.8, 3.9, 3.10, 3.11, and PyPy. See our Python version support policy for more information on when we plan to drop support for older Python versions.
Note in particular that SymPy 1.5.1 was the last release to support Python 2.7. SymPy 1.11 will not work on Python 2.7. Python 2.7 users should install SymPy 1.5.1 and will not be able to install any further SymPy updates without updating to Python 3.
Install SymPy with
pip install -U sympy
or if you use Anaconda
conda install sympy
Highlights
There are many changes in 1.11 (see below).
The following may be of special interest:
-
Better support for integrating several different types of expressions.
-
The series expansion has seen several improvements.
-
The assumption system is now fully deterministic, so it should work in multi-threaded environments.
-
A new and improved Mathematica parser.
Backwards compatibility breaks and deprecations
A number of earlier deprecated methods, functions, arguments, and attributes are removed:
as_finite_diff
in thecalculus
module- The
prec
keyword argument toFloat
- The class-specific
simplify
method forDiracDelta
(callingsimplify
onDiracDelta
works, but uses the generalsimplify
method, which in turn calls the correct simplification) - The
equal
method ofLine
- The
has_Field
andhas_Ring
methods ofDomain
- Several earlier deprecated aspects of
DimensionSystem
andUnitSystem
- Several earlier deprecations in the
vector
module - The stub submodules
sympy.printing.ccode
,sympy.printing.cxxcode
andsympy.printing.fcode
The LaTeX expression \log
is now parsed as having base E. On the other hand, parsing \lg
is now supported and parses as base 10.
The ability to skip checking the arguments, the check
argument, to MatAdd
, MatMul
, and HadamardProduct
is deprecated. Passing check=False
can lead to creating incorrect expressions that do not make sense and cause issues for other code.
The is_prime
, is_perfect_square
, and divides
methods of carmichael
are deprecated as they are just simple wrappers around other functions and not really related to Carmichael numbers.
The deprecated numpy.matrix
is replaced by numpy.ndarray
in the physics.quantum
module.
Changes
-
algebras
- Added Hamilton's operators in Quaternion class in quaternion.py. (#22713 by @mayankray2020 and @praneethratna)
-
calculus
-
Added singularity check to is_convex() (#23199 by @faze-geek and @smichr)
-
BREAKING: removed deprecated
as_finite_diff
. (#22952 by @oscargus)
-
-
combinatorics
- Added methods for nilpotent, abelian and cyclic numbers. (#23329 by @OrestisVaggelis)
-
concrete
-
A bug leading to incorrect results when evaluating some infinite summations was fixed. Previously an incorrect result might be found in some cases if the summation symbol was defined with the
integer=True
assumption set. (#23507 by @KuldeepBorkar) -
more summation are now recognized as telescopic sums (#23129 by @smichr)
-
-
core
-
Expr.as_coefficient_dict
now accepts one or more symbols so symbolic coefficients can be extracted (#23325 by @smichr) -
Fix calling symbols with Iterable not pass cls parameter (#23534 by @eagleoflqj)
-
The return values of
eval
onFunction
subclasses are now automatically sympified. (#23526 by @asmeurer) -
Function
subclasses now raise an exception if theeval
method is not defined as a@classmethod
. (#23526 by @asmeurer)
-
support string-
format
forExpr
with float precision. (#23476 by @eagleoflqj) -
Making Expr.pow type consistent by sympify the returned ints (#23378 by @airpods69)
-
A bug resulting in the core assumptions system being sometimes unreliable was fixed meaning that the assumptions system should now be fully reliable and deterministic, even in multithread usage. The fix has a side effect that any code that is used as part of an
_eval_is_*
handler for an assumptions predicate (e.g._eval_is_real
) must not recursively query another assumption on the same object (e.g. by checking something likeself.is_positive
) or it will lead to infinite recursion. Any downstream code that implements such assumption handlers will need to be reviewed for bugs of this kind. Note that it isn't necessary to query something likex.is_positive
in a handler forx.is_real
because the assumptions system already understands the relationship between these so ifx_eval_is_positive()
returns True then the system will conclude thatx.is_real
should be true. (#22557 by @oscarbenjamin)
- rational expressions formerly reported as not-integer (False) may now be correctly reported as possibly so (None) (#23289 by @smichr)
-
Improved results of evalf() based on precision (#22999 by @faze-geek)
-
BREAKING: removed deprecated
prec
keyword argument toFloat
. (#22952 by @oscargus) -
Incorrect symbolic simplification of square roots of certain power of complex numbers such as
sqrt((-1+I)**2
was fixed to correctly give the principal root. (#23653 by @oscarbenjamin)
-
-
functions
-
New function
piecewise_exclusive
which can be used to obtain aPiecewise
with non-overlapping conditions. (#23892 by @oscarbenjamin and @oscargus) -
Heaviside
rewrites as aPiecewise
with aTrue
final condition, in consistency with other functions and for betterautowrap
support. (#23769 by @oscargus) -
hyperbolic functions can be rewritten to more other hyperbolic functions. (#22993 by @oscargus)
-
Auto evaluate DiracDelta(x, 0) to DiracDelta(x) (#23670 by @eagleoflqj)
-
The symbolic Min and Max functions now respect the global evaluate flag. (#23663 by @hsiang-wu)
-
DEPRECATION:
is_prime
,is_perfect_square
, anddivides
methods ofcarmichael
deprecated. (#23104 by @oscargus) -
Fix derivative of acosh (#23568 by @eagleoflqj)
-
Improve performance of trigonometric functions (#23541 by @eendebakpt)
-
BREAKING: removed deprecated
simplify
method ofDiracDelta
. (#22952 by @oscargus)
-
-
geometry
-
idiff is more efficient at calculating derivatives (#23560 by @smichr)
-
Fixed
Circle
from equation (wrong radius in some cases; allow non-expanded equation). (#23265 by @gschintgen) -
parabolas that are not vertical or horizontal are now supported (#22792 by @smichr)
-
linear intersections of enitities defined in terms of Floats are now more robust (#22920 by @smichr)
-
BREAKING: removed deprecated
equal
method ofLine
. (#22952 by @oscargus)
-
-
integrals
-
A bug leading to an exception during integration was fixed and the handling of degenerate cases of integrals was made more deterministic and robust. (#23722 by @oscarbenjamin)
-
A bug in the Risch integration algorithm was fixed. Previously certain integrals would fail with an exception if an intermediate step generated an empty subspace. (#23717 by @oscarbenjamin)
-
Fix integrate sqrt(x**2) in risch (#23689 by @eagleoflqj)
-
Support integrate(x**n*(trig or Derivative)) (#23559 by @eagleoflqj)
-
Support integrate(poly*(a+bx+cx^2)^(n+1/2)) (#23674 by @eagleoflqj)
-
Support integral steps for DiracDelta (#23670 by @eagleoflqj)
-
Support integrate(poly/sqrt(a+bx+cx**2)) (#23608 by @eagleoflqj)
-
manualintegrate improves f(x, (a+b*x)**(p/q)) (#23642 by @eagleoflqj)
-
Fix integrate(1/sqrt(x**2-1)) (#23573 by @eagleoflqj)
-
Support integrate(sqrt(a+bx+cx**2)) (#23530 by @eagleoflqj)
-
Support integrate((d+ex)/sqrt(a+bx+cx**2)) (#23511 by @eagleoflqj)
-
Support integrate(1/sqrt(a+bx+cx**2)) (#23489 by @eagleoflqj)
-
Support integral steps for hyperbolic functions (#23379 by @eagleoflqj)
-
fix bug in Laplace transform of a derivative (#23308 by @jackschmidt)
-
Fixed polytype_integrate for max_degree inputs (#23141 by @faze-geek)
-
fixes bug in
integrals
and now double integrate with matrix does not raise an exception. (#23277 by @praneethratna)
-
-
matrices
-
Better support for computing
adjoint
,re
, andim
forIdentity
,OneMatrix
, andZeroMatrix
. (#23724 by @oscargus) -
DEPRECATION: Previously the check argument to e.g.
MatAdd
could be used to form a mathematically incorrect expression likeMatAdd(1, Matrix([1, 2](/sympy/sympy/wiki/1,-2), check=False)
. The intention of thecheck=False
argument is just as an optimization to avoid checking that all arguments are matrices with matching shapes for speed. However, it allowed creating objects that were both mathematically invalid and also break the internal invariant ofMatAdd
which expects that all of its args are of typeMatrixExp
leading to obscure failures in other routines such as printing. In SymPy 1.11 passingcheck
toMatAdd
,MatMul
andHadamardProduct
will emit a deprecation warning. In a future version of SymPy the arguments will always be checked and passing any non-Matrix argument will give an exception. (#23671 by @oscargus) -
Made type aliases for Matrix and MutableMatrix compliant with PEP 484 (#23659 by @agryman)
-
This enables mypy to recognize the type aliases (#23659 by @agryman)
- Fixed
Matrix.QRdecomposition
giving wrong results for matrices containing symbols (for most cases where zero test can automatically infer the correct results) (#23316 by @sylee957)
-
replacement of MatrixSymbol in MatrixElement requires shape to be compatible with indices to succeed (#22677 by @smichr)
-
MatrixElement now has
symbol
attributes (analogous tobase
attribute ofIndexedBase
) (#22677 by @smichr) -
eval_hyper_sum
returns as unchanged arguments for whichis_hypergeometric
is False and those which produce singularities ata
orb + 1
whereand
andb
are the lower and upper limits of evaluation, respectively. (#22677 by @smichr) -
Matrix expression derivative algorithm add support for matrix calculus. The derivative of a matrix expression by another matrix expression can now be computed and the result is either an array expression (4-dimensional) or, if two of the resulting dimensions can be suppressed, a matrix expression (2-dimensional). (#23088 by @Upabjojr)
-
-
ntheory
-
parsing
-
Latex parser allows limit direction without braces (#23756 by @eagleoflqj)
-
Bump required antlr4 python runtime to 4.10.* (#23369 by @eagleoflqj and @xrmx)
-
Latex parser supports \lg as base 10 log defined in ISO 80000-2:2019 (#23618 by @eagleoflqj)
-
BREAKING: \log is parsed as base E to be consistent with printer default (#23618 by @eagleoflqj)
-
LaTeX parser: support for fractions with no brackets. (#23694 by @eagleoflqj and @SethPoulsen)
-
add script for rebuilding autolev antlr parser (#23416 by @xrmx)
-
Latex parser supports f'(x) (#23535 by @eagleoflqj)
-
Latex parser treats \frac and \binom as atomic (needn't wrap with braces on exponent), and supports \dfrac, \tfrac (#23475 by @eagleoflqj)
-
Added the
visit_Num
function back intoast_parser.py
. (#23122 by @wermos) -
Changed the name of the
visit_Num
node visitor function tovisit_Constant
, as the former is deprecated. (#23096 by @wermos) -
New powerful Mathematica parser replacing the old one. Language support greatly improved. (#23014 by @Upabjojr)
-
-
physics.continuum_mechanics
- Started with the implementation of the Truss class by first adding the initialising methods like
add_node
andadd_member
methods along with the Documentation (#23629 by @AdvaitPote)
- Started with the implementation of the Truss class by first adding the initialising methods like
-
physics.control
-
Fixed the failing tests in control_plots module. (#23128 by @akshanshbhatt)
-
Added unit parameter to Bode's plot which returns plot accordingly. (#23074 by @faze-geek)
-
Fixed labels of magnitude and phase plots. (#23074 by @faze-geek)
-
-
physics.mechanics
- Fixed incorrect center of mass velocity bug. (#23392 by @TJStienstra)
-
physics.optics
- Added refractive index to beam parameters. (#22969 by @faze-geek)
-
physics.quantum
-
The wrapper class
OracleGateFunction
is now provided for python functions used inOracleGate
. (#22887 by @ThePauliPrinciple) -
COMPATIBILITY BREAK: The deprecated
numpy.matrix
is replaced bynumpy.ndarray
(potentially breaking downstream code). (#22295 by @oscargus)
-
-
physics.units
-
Fixed wrong dimension calculations for some mathematical functions. (#23296 by @faze-geek and @theanshm)
-
Quantity
: it is now possible to determine if a Quantity is prefixed (eg.nanometers
) with the propertyis_prefixed
. (#23218 by @dyc3) -
Quantity
: it is now possible to determine if a Quantity represents a physics constant (eg.speed_of_light
) with the propertyis_physical_constant
or if is an instance of the new subclassPhysicalConstant
. (#23218 by @dyc3) -
quantity_simplify()
can now simplify units across dimensions using the optional flagacross_dimensions=True
. (#23218 by @dyc3) -
BREAKING: removed deprecated
print_unit_base
method ofUnitSystem
. (#22952 by @oscargus) -
BREAKING: removed deprecated
desc
andname
keyword arguments ofDimensionSystem
. (#22952 by @oscargus) -
BREAKING: removed deprecated
description
andname
keyword arguments ofDimensionSystem.extend
. (#22952 by @oscargus) -
BREAKING: removed deprecated
sort_dims
method ofDimensionSystem
. (#22952 by @oscargus) -
BREAKING: removed deprecated ability to call a
DimensionSystem
. (#22952 by @oscargus) -
BREAKING: removed deprecated ability to get an item from a
DimensionSystem
. (#22952 by @oscargus)
-
-
physics.vector
-
Point.acc() will compute acceleration from the point's position vector when the point's velocity is not yet defined. (#23628 by @moorepants and @TJStienstra)
-
Fixed bug in the calculation of the velocity of a point. (#23362 by @TJStienstra)
-
More informative error message if args are swapped in Vector.diff() (#23372 by @moorepants)
-
Restored pre-1.7 simplest form for body fixed angular velocities. (#23171 by @moorepants)
-
Adds a new method to physics vectors that extracts the functions of time:
.free_dynamicsymbols()
. (#23111 by @moorepants) -
Physics Vector differentiation now outputs simpler expressions. (#23082 by @moorepants)
-
-
plotting
-
polys
-
Numerical calculations in
minpoly
were made more robust fixing a bug that failed to compute the minimal polynomial for certain complicated algebraic expressions. (#23717 by @oscarbenjamin) -
Repair representation of prime ideals for inert primes (#23450 by @skieffer)
-
Provide method to reduce an algebraic number to a small representative mod an ideal. (#23409 by @skieffer)
-
Lazy interval calculation for
CRootOf
on irreducible polys (#23426 by @skieffer) -
Repair a bug in HNF for m x n matrices with n < m. (#23413 by @skieffer)
-
Support setting of an alias for the primitive element of an
AlgebraicField
(#23339 by @skieffer) -
Improve equal degree factorization mod powers of 2. (#23175 by @skieffer)
-
fixed bug in
primitive_element
which now does not raise zero divisor error when zero is present in the input. (#23099 by @praneethratna) -
Add convenience constructors for
AlgebraicField
(#22973 by @skieffer) -
BREAKING: removed deprecated
has_Field
andhas_Ring
methods ofDomain
. (#22952 by @oscargus)
-
-
printing
-
The Aesara printer no longer uses the deprecated Aesara functions
abs_
,and_
,or_
andxor
. (#23958 by @oscarbenjamin) -
preview
now supports aviewer=system_default_viewer
argument, which is now the default on windows and used as a final fallback on all platforms. (#23800 by @oscarbenjamin) -
cot
,sec
,csc
and related inverse and hyperbolic functions are automatically rewritten if they cannot be printed. Enableslambdify
for these expressions. (#22993 by @oscargus) -
Add extra spaces around binary operators to the result of
julia_code()
by default. (#23729 by @cocolato) -
Added
JaxPrinter
, allowingsympy.lambdify
to operate on and produce JAX functions. Example:f = lambdify(variables, expr, 'jax')
. (#23627 by @tttc3) -
BREAKING CHANGE: The deprecated stub submodules
sympy.printing.ccode
,sympy.printing.cxxcode
andsympy.printing.fcode
have been removed. These modules were renamed to e.g.sympy.printing.c
in SymPy 1.7 but deprecated stub modules were left behind to give a warning to anyone doingfrom sympy.printing.ccode import ccode
that they should change their imports. Those deprecated stub modules are now removed. The reason for this change was because of ambiguity when writingfrom sympy.printing import ccode
which might import theccode
submodule or theccode
function defined in the submodule. Even continuing to test these deprecated stub modules caused problems in the test suite precisely because of this ambiguity so the modules are now removed completely. The functions that used to be defined in these modules are still available as e.g.from sympy import ccode, cxxcode, fcode
(as they have been since before 1.7). (#23660 by @oscarbenjamin) -
LaTeX-printing of Prefix is supported. (#23646 by @oscargus)
-
Reciprocals are printed as divisions in Python printers. (#23649 by @oscargus)
-
The llvmjit printer now works with Python 3.10. Previously a bug caused it to segfault. (#23513 by @oscarbenjamin)
-
The function names in the LaTeX printer, take the include sub- and superscripts into account then determining the name length. (e.g.: now
a_1
is interpreted as a one letter name with subscript) (#23448 by @Alex031544 and @eagleoflqj) -
Corrected LaTeX- and pretty-printing of Adjoint, Determinant, Inverse, and Transpose. (#22773 by @dispasha and @oscargus)
-
LaTeX printing of elements of
AlgebraicField
s is repaired (in terms of both speed and appearance). (#23339 by @skieffer) -
NumExprPrinter
now handles codegen AST objects. (#23196 by @ThePauliPrinciple) -
Allow to configure differential operator in latex printer. Default is "d". (#23239 by @eagleoflqj)
-
Fixed a bug in pretty_print, where sympy.vector objects were being incorrectly printed in certain cases. (#23191 by @wermos)
-
The LaTeX printer now uses
\Delta
instead of\triangle
for the Laplace operator. (#23200 by @wermos) -
NumPyPrinter
andTensorflowPrinter
have improved support for array expressions. (#22950 by @ThePauliPrinciple)
-
-
series
-
Fixes leading term for exponential functions involving AccumBounds based arguments for limits being calculated at NegativeInfinity. (#23753 by @faze-geek)
-
Refactored leading term method for log Function. (#23592 by @anutosh491)
-
Added logx parameter to leading term methods of type add and power. (#23592 by @anutosh491)
-
Introduced arg_flag in Limit.doit.set_signs. (#23592 by @anutosh491)
-
Fixed leading term method for Ei, Chi and bessely functions. (#23592 by @anutosh491)
-
Implemented branch cut handling for leading term methods of inverse trigonometric functions. (#23592 by @anutosh491)
-
Fixed nseries for nested logarithms where logx parameter passed is not None. (#23592 by @anutosh491)
-
Fixes integral for probability distribution function of cauchy distribution (#23592 by @anutosh491)
-
fixes bug in
series
and now series expansion with float does not giveNotImplementedError
. (#23456 by @praneethratna) -
Fixes limit computations where arg0 would evaluate to S.NaN for the ceiling and floor functions. (#23258 by @anutosh491)
-
Fixed leading term method inconsistency for expressions involving variables in powers. (#23241 by @anutosh491)
-
Fixes leading term for exponential functions involving AccumBounds based arguments. (#23127 by @anutosh491)
-
Improved Consistency between basic limits and added _eval_as_leading_term for csc function. (#22905 by @anutosh491)
-
Fixes series for expressions of type Pow having unspecified exponents (#22870 by @anutosh491)
-
-
simplify
-
solvers
-
A bug preventing solveset from properly handling equations that can be factored was fixed. (#23691 by @oscarbenjamin)
-
A bug that caused an AttributeError when solving some equations or evaluating some integrals with radicals was fixed. (#23717 by @oscarbenjamin)
-
non-symbols are now replaced with symbols that sort in the same order as the original objects (#23703 by @smichr)
-
returned dictionaries are sorted by keys so a solution is easier to find visually (#23703 by @smichr)
-
A number of incorrect results from rsolve fixed by backport/cherry-pick from diofant (by @skirpichev) (#23567 by @ehren and @skirpichev)
-
A bug was fixed in the hypergeometric solver so that
classify_ode()
does not raisePolynomialError
for certain ODEs. (#23478 by @praneethratna) -
A bug leading to incorrect solutions of some radical equations from
solveset
was fixed. (#23341 by @maurogaravello) -
nonlinsolve now handles all polynomial equations using polynomial methods. (#23011 by @NikhilSDate)
-
solve_poly_system accepts a keyword argument strict and raises NotImplementedError if it is not able to find a complete solution and strict is True (#23011 by @NikhilSDate)
-
solve_generic accepts a keyword argument strict and raises NotImplementedError if it is not able to find a complete solution and strict is True (#23011 by @NikhilSDate)
-
improved detection of Lambert solutions when a power of x appear in
log
(#23255 by @praneethratna and @smichr) -
solve will give more factored results automatically when solving binomial expressions with similar powers in the constant term -- like when solving
x**3 - (1 - y)**6
forx
. (#22781 by @smichr) -
bug involving error sometimes raised when using the
as_set=True
flag was fixed (#23182 by @smichr) -
a bug fix in checking solutions now allows more complete solutions to some nonlinear systems using
solve
(#22719 by @smichr) -
use of the flag
quick
wthout settingparticular=True
will raise an error (#22719 by @smichr) -
an error is raised if
particular
is True but a single equation (not in a list) was passed tosolve
(#22719 by @smichr) -
when using
particular=True
an error is no longer raised when a solution compatible with assumptions is not found (#22719 by @smichr) -
a bug where less than complete solutions were being returned for systems of equations from
solve
was addressed (#22719 by @smichr) -
checksol no longer produces an error if ints or floats are passed as equations (#22866 by @NikhilSDate and @smichr)
-
Added
Min
/Max
support fordecompogen
. (#23021 by @praneethratna and @smichr)
-
-
stats
-
The PyMC3 library that can optionally be used for random sampling is now replaced by PyMC version 4. It is still possible to install and use
pymc3
as SymPy tries to select an available version, but for new code it is recommended to usepymc
. (#23678 by @oscargus) -
Registered more distributions that can be sampled using numpy. (#23346 by @KuldeepBorkar)
-
removed deprecation warning about using
evaluate=False
(#22677 by @smichr)
-
-
testing
-
utilities
-
The namespace used by
lambdify
to execute the functions it creates no longer usesfrom scipy import *
. This change is not expected to have any observable effect since the code generated by SymPy's code printers do not use anything that would be imported in that way. It is possible though that in a future version of SciPyfrom scipy import *
might raiseImportError
in which case it would be necessary to use version SymPy 1.11 or greater with that version of SciPy. At the time of writing there is a PR to prevent this change in SciPy (https://github.com/scipy/scipy/pull/16854). However if that or something equivalent is not merged then SciPy versions from 1.10.0 onwards will be incompatible with SymPy versions before 1.11. (#23946 by @oscarbenjamin) -
The autowrap module now sets
language_level = 3
in the generated Cython code. (#23754 by @oscarbenjamin) -
Dummies now replaced in lambdify cse subexpressions. (#23538 by @moorepants)
-
It is now possible to use
lambdify
with NumPy while running under PyPy. (#23461 by @eagleoflqj and @extraymond)
-
-
vector
-
Scalar condition of vectors made False (#23033 by @faze-geek)
-
BREAKING: removed deprecated
CoordSysCartesian
class. (#22952 by @oscargus) -
BREAKING: removed deprecated
delop
method ofCoordSys3D
. (#22952 by @oscargus) -
BREAKING: removed deprecated
system
keyword argument ofDel
. (#22952 by @oscargus) -
BREAKING: removed deprecated
coord_sys
keyword argument ofcurl
,divergence
, andgradient
. (#22952 by @oscargus)
-
-
other
- A new, user-friendly page on solving an equation algebraically was added to the Guides section. (#23862 by @bertiewooster)
- Clean up the top-level organization in the documentation. (#23799 by @asmeurer and @oscarbenjamin)
-
Add documentation about the joints framework in the physics/mechanics module. (#23730 by @TJStienstra)
-
Added a four bar linkage example which uses the joints framework (#23705 by @TJStienstra)
- A new, user-friendly page on solving of various types in SymPy was added to the Guides page. (#23462 by @bertiewooster)
-
Add the sphinx-copybutton extension to the docs. (#23335 by @asmeurer)
-
The documentation now uses the Furo Sphinx theme. (#23159 by @asmeurer and @bertiewooster)
- Fixed several issues with
__slots__
(overlaps and omission in base classes) (#22924 by @ariebovenberg)