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 the calculus module
  • The prec keyword argument to Float
  • The class-specific simplify method for DiracDelta (calling simplify on DiracDelta works, but uses the general simplify method, which in turn calls the correct simplification)
  • The equal method of Line
  • The has_Field and has_Ring methods of Domain
  • Several earlier deprecated aspects of DimensionSystem and UnitSystem
  • Several earlier deprecations in the vector module
  • The stub submodules sympy.printing.ccode, sympy.printing.cxxcode and sympy.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

  • calculus

  • combinatorics

  • 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 on Function subclasses are now automatically sympified. (#23526 by @asmeurer)

    • Function subclasses now raise an exception if the eval method is not defined as a @classmethod. (#23526 by @asmeurer)

    • support string-format for Expr 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 like self.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 like x.is_positive in a handler for x.is_real because the assumptions system already understands the relationship between these so if x_eval_is_positive() returns True then the system will conclude that x.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 to Float. (#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 a Piecewise with non-overlapping conditions. (#23892 by @oscarbenjamin and @oscargus)

    • Heaviside rewrites as a Piecewise with a True final condition, in consistency with other functions and for better autowrap 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, and divides methods of carmichael deprecated. (#23104 by @oscargus)

    • Fix derivative of acosh (#23568 by @eagleoflqj)

    • Improve performance of trigonometric functions (#23541 by @eendebakpt)

    • BREAKING: removed deprecated simplify method of DiracDelta. (#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 of Line. (#22952 by @oscargus)

  • integrals

  • matrices

    • Better support for computing adjoint, re, and im for Identity, OneMatrix, and ZeroMatrix. (#23724 by @oscargus)

    • DEPRECATION: Previously the check argument to e.g. MatAdd could be used to form a mathematically incorrect expression like MatAdd(1, Matrix([1, 2](/sympy/sympy/wiki/1,-2), check=False). The intention of the check=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 of MatAdd which expects that all of its args are of type MatrixExp leading to obscure failures in other routines such as printing. In SymPy 1.11 passing check to MatAdd, MatMul and HadamardProduct 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 to base attribute of IndexedBase ) (#22677 by @smichr)

    • eval_hyper_sum returns as unchanged arguments for which is_hypergeometric is False and those which produce singularities at a or b + 1 where and and b 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

    • isprime extend deterministic solutions to over 2^81 (#23455 by @oittaa)

    • isprime: test with pow(2, n, n) up to 31417 (#23454 by @oittaa)

    • Remove dead code paths from jacobi_symbol (#23445 by @oittaa)

  • 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 into ast_parser.py. (#23122 by @wermos)

    • Changed the name of the visit_Num node visitor function to visit_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 and add_member methods along with the Documentation (#23629 by @AdvaitPote)
  • physics.control

  • physics.mechanics

  • physics.optics

  • physics.quantum

    • The wrapper class OracleGateFunction is now provided for python functions used in OracleGate. (#22887 by @ThePauliPrinciple)

    • COMPATIBILITY BREAK: The deprecated numpy.matrix is replaced by numpy.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 property is_prefixed. (#23218 by @dyc3)

    • Quantity: it is now possible to determine if a Quantity represents a physics constant (eg. speed_of_light) with the property is_physical_constant or if is an instance of the new subclass PhysicalConstant. (#23218 by @dyc3)

    • quantity_simplify() can now simplify units across dimensions using the optional flag across_dimensions=True. (#23218 by @dyc3)

    • BREAKING: removed deprecated print_unit_base method of UnitSystem. (#22952 by @oscargus)

    • BREAKING: removed deprecated desc and name keyword arguments of DimensionSystem. (#22952 by @oscargus)

    • BREAKING: removed deprecated description and name keyword arguments of DimensionSystem.extend. (#22952 by @oscargus)

    • BREAKING: removed deprecated sort_dims method of DimensionSystem. (#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

    • Enable sympy.plotting.plot_contour (#23591 by @zaz)

    • Labels etc can be set to expressions, including the default values, and are latexified using the Matplotlib backend. (#23091 by @oscargus)

  • 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)

    • Improve printing for PrimeIdeal (#23404 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 and has_Ring methods of Domain. (#22952 by @oscargus)

  • printing

    • The Aesara printer no longer uses the deprecated Aesara functions abs_, and_, or_ and xor. (#23958 by @oscarbenjamin)

    • preview now supports a viewer=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. Enables lambdify 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, allowing sympy.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 and sympy.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 doing from 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 writing from sympy.printing import ccode which might import the ccode submodule or the ccode 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)

    • Fixed a bug with Array printing (#23622 by @viocha)

    • 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 AlgebraicFields 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 and TensorflowPrinter 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 give NotImplementedError. (#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

    • collect will now allow collection of coefficients in products of generators to be collected when exact=None (#23757 by @smichr)
  • 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)

    • Allow initial conditions of the form {f(0): f(0)} in dsolve(). (#23708 by @asmeurer)
    • 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 raise PolynomialError 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 for x. (#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 setting particular=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 to solve (#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 for decompogen. (#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 use pymc. (#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 uses from 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 SciPy from scipy import * might raise ImportError 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)

    • Pass keyword arguments of filldedent() through to textwrap.fill(). (#23193 by @asmeurer)
    • itertools.subsets() and itertools.variations() should be a bit faster. The return type of these functions now depends on the arguments, but is always an iterator. In particular, isinstance(result, collections.abc.Iterator) should always be True. (#23063 by @rathmann)
  • vector

    • Scalar condition of vectors made False (#23033 by @faze-geek)

    • BREAKING: removed deprecated CoordSysCartesian class. (#22952 by @oscargus)

    • BREAKING: removed deprecated delop method of CoordSys3D. (#22952 by @oscargus)

    • BREAKING: removed deprecated system keyword argument of Del. (#22952 by @oscargus)

    • BREAKING: removed deprecated coord_sys keyword argument of curl, divergence, and gradient. (#22952 by @oscargus)

  • other

    • A new, user-friendly page on solving an equation algebraically was added to the Guides section. (#23862 by @bertiewooster)
    • 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)
    • Fixed several issues with __slots__ (overlaps and omission in base classes) (#22924 by @ariebovenberg)

Authors