hash
stringlengths
64
64
content
stringlengths
0
1.51M
5ee6e2f5aae87b313431b6b9498ab41e21c414c030803aaa3e7e08b503f4e425
from itertools import combinations from sympy.combinatorics.graycode import GrayCode class Subset(): """ Represents a basic subset object. Explanation =========== We generate subsets using essentially two techniques, binary enumeration and lexicographic enumeration. The Subset class tak...
c3dd7e80b1efcea87fdaa94ce021520069145e389a71c99baa423f263d54efa7
""" The Schur number S(k) is the largest integer n for which the interval [1,n] can be partitioned into k sum-free sets.(http://mathworld.wolfram.com/SchurNumber.html) """ import math from sympy.core import S from sympy.core.basic import Basic from sympy.core.function import Function from sympy.core.numbers import Inte...
68380b559b8e58c5e0dc1017392a56b15022fec044a4fd95869b1af821993258
from typing import Dict as tDict, List from sympy.core import S from sympy.core.expr import Expr from sympy.core.symbol import Symbol, symbols as _symbols from sympy.core.sympify import CantSympify from sympy.printing.defaults import DefaultPrinting from sympy.utilities import public from sympy.utilities.iterables imp...
134a2d9fbd903d19ea22366c37074c2f058f4e1b7760962f86df11876c1f602e
from sympy.combinatorics.permutations import Permutation, _af_rmul, \ _af_invert, _af_new from sympy.combinatorics.perm_groups import PermutationGroup, _orbit, \ _orbit_transversal from sympy.combinatorics.util import _distribute_gens_by_base, \ _orbits_transversals_from_bsgs """ References for tensor ...
983124cb193dc49745cc6023ce1966ab0e832a4f201a963a266ca914e1bd55f5
from sympy.ntheory.primetest import isprime from sympy.combinatorics.perm_groups import PermutationGroup from sympy.printing.defaults import DefaultPrinting from sympy.combinatorics.free_groups import free_group class PolycyclicGroup(DefaultPrinting): is_group = True is_solvable = True def __init__(self...
dd1a32fa56b3b05127cfe65f58fe0e20ed1227351603e30b7f14d2cca6754eec
from sympy.combinatorics import Permutation as Perm from sympy.combinatorics.perm_groups import PermutationGroup from sympy.core import Basic, Tuple, default_sort_key from sympy.sets import FiniteSet from sympy.utilities.iterables import (minlex, unflatten, flatten) from sympy.utilities.misc import as_int rmul = Perm....
0ed65f829edba433ea254957704bcef9aa407bd36eba395ecae392ad1807168e
import itertools from sympy.combinatorics.fp_groups import FpGroup, FpSubgroup, simplify_presentation from sympy.combinatorics.free_groups import FreeGroup from sympy.combinatorics.perm_groups import PermutationGroup from sympy.core.numbers import igcd from sympy.ntheory.factor_ import totient from sympy.core.singleton...
44c743076ae0c72c53f1d5ba806416c601de3db5f5bd2fdcb646fb7614eb1b95
from sympy.core import Basic, Dict, sympify from sympy.core.sorting import default_sort_key from sympy.core.sympify import _sympify from sympy.functions.combinatorial.numbers import bell from sympy.matrices import zeros from sympy.sets.sets import FiniteSet, Union from sympy.utilities.iterables import flatten, group fr...
528406cb222c3762873f5d37879e5d87483d1008fe7b2b171e098c418972bab3
from sympy.combinatorics.permutations import Permutation, _af_invert, _af_rmul from sympy.ntheory import isprime rmul = Permutation.rmul _af_new = Permutation._af_new ############################################ # # Utilities for computational group theory # ############################################ def _base_or...
3b4f72b1885a134840bfac302040387247e075aca6d4ff4c5c33f49c266f25e7
from sympy.combinatorics.free_groups import free_group from sympy.printing.defaults import DefaultPrinting from itertools import chain, product from bisect import bisect_left ############################################################################### # COSET TABLE ...
9abc5e5de5be78739b2ae86703ea14e60b3d19967a24c48c26fb2c0ac8d44821
from sympy.core import Basic from sympy.utilities.iterables import flatten, iterable from sympy.utilities.misc import as_int from collections import defaultdict class Prufer(Basic): """ The Prufer correspondence is an algorithm that describes the bijection between labeled trees and the Prufer code. A Pru...
4846e43e29ee152580e401e36e793442860c3712fc6f9b6ec78bd27ffad2e462
"""Finitely Presented Groups and its algorithms. """ from sympy.core.singleton import S from sympy.core.symbol import symbols from sympy.combinatorics.free_groups import (FreeGroup, FreeGroupElement, free_group) from sympy.combinatorics.rewritingsystem import RewritingSy...
c81156a7015a561bfcfa65f2872b0eca3e6ccf77fbe5e5ef4bd3c3054856f7d0
from typing import Tuple as tTuple from .expr_with_intlimits import ExprWithIntLimits from .summations import Sum, summation, _dummy_with_inherited_properties_concrete from sympy.core.expr import Expr from sympy.core.exprtools import factor_terms from sympy.core.function import Derivative from sympy.core.mul import Mu...
872205c9beb3acbc41021572372a148c938ae7fbbf92aacfa109a937b06a169f
""" This module implements sums and products containing the Kronecker Delta function. References ========== .. [1] http://mathworld.wolfram.com/KroneckerDelta.html """ from .products import product from .summations import Sum, summation from sympy.core import Add, Mul, S, Dummy from sympy.core.cache import cacheit f...
79f35275ad1487b1261bdeeb8b9804546b0e538afe9cf792543c3f3668de201e
"""Gosper's algorithm for hypergeometric summation. """ from sympy.core import S, Dummy, symbols from sympy.polys import Poly, parallel_poly_from_expr, factor from sympy.solvers import solve from sympy.simplify import hypersimp from sympy.utilities.iterables import is_sequence def gosper_normal(f, g, n, polys=True):...
fd47e5c6553bc9c8464a6782aeb114d2473aeed2dc1aa360ed248330119fec30
"""Various algorithms for helping identifying numbers and sequences.""" from sympy.utilities import public from sympy.core import Function, Symbol, S from sympy.core.numbers import Zero from sympy.concrete.products import (Product, product) from sympy.core.numbers import (Integer, Rational) from sympy.core.symbol imp...
255bfa0edcd31745a3798a585625e0d2693fde617598661647980a28ddbedb29
from sympy.core.add import Add from sympy.core.containers import Tuple from sympy.core.expr import Expr from sympy.core.function import AppliedUndef, UndefinedFunction from sympy.core.mul import Mul from sympy.core.relational import Equality, Relational from sympy.core.singleton import S from sympy.core.symbol import S...
3aea2d5f4b9e756aaf991136cd2e20e0d9d513ad7442f12b096d3877d189495f
from typing import Tuple as tTuple from sympy.calculus.singularities import is_decreasing from sympy.calculus.util import AccumulationBounds from .expr_with_intlimits import ExprWithIntLimits from .expr_with_limits import AddWithLimits from .gosper import gosper_sum from sympy.core.expr import Expr from sympy.core.add...
95651bbec7bdde2d90a92c743fdf22781f50d6fd004ec1ea1d8201152747986c
"""Tools to assist importing optional external modules.""" import sys import re # Override these in the module to change the default warning behavior. # For example, you might set both to False before running the tests so that # warnings are not printed to the console, or set both to True for debugging. WARN_NOT_INS...
f7a350281254baa594372c35fa0805b3007bde9cfba5e75da04f445b31af203f
""" PythonMPQ: Rational number type based on Python integers. This class is intended as a pure Python fallback for when gmpy2 is not installed. If gmpy2 is installed then its mpq type will be used instead. The mpq type is around 20x faster. We could just use the stdlib Fraction class here but that is slower: from...
5776741d0ca0ed23a0be2c0ebc18a4f1d52d4b13baca236a16a8c04678d33b72
import os from typing import Tuple as tTuple, Type import mpmath.libmp as mlib from sympy.external import import_module __all__ = [ # GROUND_TYPES is either 'gmpy' or 'python' depending on which is used. If # gmpy is installed then it will be used unless the environment variable # SYMPY_GROUND_TYPES is s...
19cfeff0e96595f96c087cdd387a4d5dd6bf79bd2474a55b523207b796e74d00
from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.utilities import public @public def approximants(l, X=Symbol('x'), simplify=False): """ Return a generator for consecutive Pade approximants for a series. It can also be used for computing the rational generating function of...
f554c23843a02323af7308d8e594ff73891613e7ff6cbefd8b3fd3dd61a2b3de
""" Convergence acceleration / extrapolation methods for series and sequences. References: Carl M. Bender & Steven A. Orszag, "Advanced Mathematical Methods for Scientists and Engineers: Asymptotic Methods and Perturbation Theory", Springer 1999. (Shanks transformation: pp. 368-375, Richardson extrapolation: pp. 375-3...
b5a7c724f8e8fb8fc48ad71c319bceb3b584a176b770ce064e48f43206d0deac
""" Limits ====== Implemented according to the PhD thesis http://www.cybertester.com/data/gruntz.pdf, which contains very thorough descriptions of the algorithm including many examples. We summarize here the gist of it. All functions are sorted according to how rapidly varying they are at infinity using the followin...
443a5147ab74cd0fbfa9d57dc597ed6cd1d6a75ed0ef91e3169e7bd4b90848fd
from sympy.core.basic import Basic from sympy.core.cache import cacheit from sympy.core.containers import Tuple from sympy.core.decorators import call_highest_priority from sympy.core.parameters import global_parameters from sympy.core.function import AppliedUndef from sympy.core.mul import Mul from sympy.core.numbers ...
bdf3bf5ef4e9253cb77d9a79b0e7de66d827c03de0de1010e371bf5672a3a4d1
from sympy.core import S, Symbol, Add, sympify, Expr, PoleError, Mul from sympy.core.exprtools import factor_terms from sympy.core.numbers import Float from sympy.functions.combinatorial.factorials import factorial from sympy.functions.elementary.complexes import (Abs, sign) from sympy.functions.elementary.exponential ...
0babad48ae2f130d106e17c436f3f80f7a8ba0a856d1334618bfb43104a07b51
"""Fourier Series""" from sympy.core.numbers import (oo, pi) from sympy.core.symbol import Wild from sympy.core.expr import Expr from sympy.core.add import Add from sympy.core.containers import Tuple from sympy.core.singleton import S from sympy.core.symbol import Dummy, Symbol from sympy.core.sympify import sympify f...
938eacfdf15f20774966a7ecb7e07ff97d51f92016b3fad1f4c407edaf492ed8
""" This module implements the Residue function and related tools for working with residues. """ from sympy.core.mul import Mul from sympy.core.singleton import S from sympy.core.sympify import sympify from sympy.utilities.timeutils import timethis @timethis('residue') def residue(expr, x, x0): """ Finds the...
a5df82bb8538e9e5486838d65330d046a8b105c72c3667dd419a0b0afa6e43f8
"""Formal Power Series""" from collections import defaultdict from sympy.core.numbers import (nan, oo, zoo) from sympy.core.add import Add from sympy.core.expr import Expr from sympy.core.function import Derivative, Function, expand from sympy.core.mul import Mul from sympy.core.numbers import Rational from sympy.cor...
8951c367a56c3fa0ca3f29034a7640a34a28273beebf692d05e1bb4d04bbd9fb
from sympy.core import S, sympify, Expr, Dummy, Add, Mul from sympy.core.cache import cacheit from sympy.core.containers import Tuple from sympy.core.function import Function, PoleError, expand_power_base, expand_log from sympy.core.sorting import default_sort_key from sympy.sets.sets import Complement from sympy.utili...
0b4fe4adf990484ef8664e422f03a356bf541d9a08ee8fa87c49c8b08c091588
""" Expand Hypergeometric (and Meijer G) functions into named special functions. The algorithm for doing this uses a collection of lookup tables of hypergeometric functions, and various of their properties, to expand many hypergeometric functions in terms of special functions. It is based on the following paper: ...
65309a39d3ab82d89f5b1426173ca782b2eaf6ec3307205d8924b9984f830e81
""" Optimizations of the expression tree representation for better CSE opportunities. """ from sympy.core import Add, Basic, Mul from sympy.core.singleton import S from sympy.core.sorting import default_sort_key from sympy.core.traversal import preorder_traversal def sub_pre(e): """ Replace y - x with -(x - y) if...
6965da09d653280b3370ab1ef2fd0744683cdeb7aebd2c62e5ef7bb1a7c670b0
from collections import defaultdict from sympy.core import (Basic, S, Add, Mul, Pow, Symbol, sympify, expand_func, Function, Dummy, Expr, factor_terms, expand_power_exp, Eq) from sympy.core.exprtools import factor_nc from sympy.core.parameters import global_parameters fr...
307d6f9301ead09e6d366eecb3c57abfe9a3ac31945f07ceb1aae22307e2dfc7
"""The module helps converting SymPy expressions into shorter forms of them. for example: the expression E**(pi*I) will be converted into -1 the expression (x+x)**2 will be converted into 4*x**2 """ from .simplify import (simplify, hypersimp, hypersimilar, logcombine, separatevars, posify, besselsimp, kroneckersim...
33e8c6eb66183f7c57004b605d9117c38baf037342d1ea9ab1716c1c04b9902e
from sympy.core.traversal import use as _use from sympy.utilities.decorator import deprecated use = deprecated( useinstead="sympy.core.traversal.use", deprecated_since_version="1.10", issue=22288)(_use)
bd5d3a2d04acfe895ef267983ce93a2c6acabb1df28b012b34ae1ce26c22ca93
from collections import defaultdict from sympy import SYMPY_DEBUG from sympy.core import sympify, S, Mul, Derivative, Pow from sympy.core.add import _unevaluated_Add, Add from sympy.core.assumptions import assumptions from sympy.core.exprtools import Factors, gcd_terms from sympy.core.function import _mexpand, expand...
604792e5a998b1e4f59c2e1b1eacb27a6ae3004d6a9615b3d08497264e48f17a
"""Tools for manipulation of expressions using paths. """ from sympy.core import Basic class EPath: r""" Manipulate expressions using paths. EPath grammar in EBNF notation:: literal ::= /[A-Za-z_][A-Za-z_0-9]*/ number ::= /-?\d+/ type ::= literal attribute ::= ...
5d93b23fcab1a30b1735baed7548a29d415351abb80d9be2be677ef82c3c2679
from sympy.core import Mul from sympy.core.function import count_ops from sympy.core.traversal import preorder_traversal, bottom_up from sympy.functions.combinatorial.factorials import binomial, factorial from sympy.functions import gamma from sympy.simplify.gammasimp import gammasimp, _gammasimp from sympy.utilities....
53884d63e147bc110df02ac2881b5671c416de7cfafc748bdca82cc40cfe7f22
from sympy.core import Add, Expr, Mul, S, sympify from sympy.core.function import _mexpand, count_ops, expand_mul from sympy.core.sorting import default_sort_key from sympy.core.symbol import Dummy from sympy.functions import root, sign, sqrt from sympy.polys import Poly, PolynomialError def is_sqrt(expr): """Ret...
37fd91640bcf1161321ad0bb2c7f411bcec26e4293c625a1e1b4801f2f7f845f
from collections import defaultdict from functools import reduce from sympy.core.function import expand_log, count_ops from sympy.core import sympify, Basic, Dummy, S, Add, Mul, Pow, expand_mul, factor_terms from sympy.core.sorting import ordered, default_sort_key from sympy.core.numbers import Integer, Rational from ...
8aa3b3f324858dc331f231c40ee35cda87be6d60ca6cb0f1e1284ce82d15c6f6
from sympy.core import Function, S, Mul, Pow, Add from sympy.core.sorting import ordered, default_sort_key from sympy.core.function import count_ops, expand_func from sympy.functions.combinatorial.factorials import binomial from sympy.functions import gamma, sqrt, sin from sympy.polys import factor, cancel from sympy....
b221d07fc3a8c1cde02b3553e570ff348483a20fde3f43ce1d7bf9f949fee009
from collections import defaultdict from functools import reduce from sympy.core import (sympify, Basic, S, Expr, factor_terms, Mul, Add, bottom_up) from sympy.core.cache import cacheit from sympy.core.function import (count_ops, _mexpand, FunctionClass, expand, ...
94342506c88ae32652b096178179633620aaabf1839b0965fdcc7301ed690756
""" Tools for doing common subexpression elimination. """ from sympy.core import Basic, Mul, Add, Pow, sympify from sympy.core.containers import Tuple, OrderedSet from sympy.core.exprtools import factor_terms from sympy.core.singleton import S from sympy.core.sorting import ordered from sympy.core.symbol import symbols...
55fb7d2a4f4b56de8b5eb8eeff13e6da86e1ad73b2bfa2bdac8a534f3db0916d
from collections import defaultdict from sympy.core.add import Add from sympy.core.expr import Expr from sympy.core.exprtools import Factors, gcd_terms, factor_terms from sympy.core.function import expand_mul from sympy.core.mul import Mul from sympy.core.numbers import pi, I from sympy.core.power import Pow from symp...
13c003d268fc50bb5e94349492624a258ee4626e5f55f08be101ff0d7eb9a84c
""" This module cooks up a docstring when imported. Its only purpose is to be displayed in the sphinx documentation. """ from sympy.core.relational import Eq from sympy.functions.special.hyper import hyper from sympy.printing.latex import latex from sympy.simplify.hyperexpand import FormulaCollection c = FormulaC...
9dc56d44f1801f4873fc3031b1c3b990d3b8cc4e42c71d41d4df9ea4fcbe7b1e
from itertools import combinations_with_replacement from sympy.core import symbols, Add, Dummy from sympy.core.numbers import Rational from sympy.polys import cancel, ComputationFailed, parallel_poly_from_expr, reduced, Poly from sympy.polys.monomials import Monomial, monomial_div from sympy.polys.polyerrors import Dom...
d4bb997f2b6c35e55343e522f5aaa07029a79da91eddaf8ec1bc795705175b84
r""" This module contains the functionality to arrange the nodes of a diagram on an abstract grid, and then to produce a graphical representation of the grid. The currently supported back-ends are Xy-pic [Xypic]. Layout Algorithm ================ This section provides an overview of the algorithms implemented in :cl...
1b7c0288d0a03624cb2c567118b7766459a7b1b891c616a949f656956482e74f
from sympy.core import S, Basic, Dict, Symbol, Tuple, sympify from sympy.core.symbol import Str from sympy.sets import Set, FiniteSet, EmptySet from sympy.utilities.iterables import iterable class Class(Set): r""" The base class for any kind of class in the set-theoretic sense. Explanation ==========...
829b3d9671a71ecf9ffebadd11b3bd192b2f1bc5a204eb555ef2ddd2bd46f146
from sympy.core.numbers import Rational from sympy.core.singleton import S from sympy.functions.elementary.complexes import (conjugate, im, re, sign) from sympy.functions.elementary.exponential import (exp, log as ln) from sympy.functions.elementary.miscellaneous import sqrt from sympy.functions.elementary.trigonometri...
83b2d046c557b92adbae189699deda0a2a52a9237cbd750206977fb9b504cd21
"""Predefined R^n manifolds together with common coord. systems. Coordinate systems are predefined as well as the transformation laws between them. Coordinate functions can be accessed as attributes of the manifold (eg `R2.x`), as attributes of the coordinate systems (eg `R2_r.x` and `R2_p.theta`), or by using the us...
e2e51e07905547e36c56890c55b72c2a2fe50b39b5d39d28154b4b57d9854e9d
from typing import Any, Set as tSet from functools import reduce from itertools import permutations from sympy.combinatorics import Permutation from sympy.core import ( Basic, Expr, Function, diff, Pow, Mul, Add, Lambda, S, Tuple, Dict ) from sympy.core.cache import cacheit from sympy.core.symbol import Symb...
1df17a48fef5d18ef213165c49eb08d2eb156838967443c498cb72303dc9b4e6
from sympy.printing.pycode import PythonCodePrinter """ This module collects utilities for rendering Python code. """ def render_as_module(content, standard='python3'): """Renders Python code as a module (with the required imports). Parameters ========== standard : See the parameter ``stand...
19bf80903558faf22ecaca360fff3112d92637f4d66362f0f5c03179583c1a63
""" AST nodes specific to the C family of languages """ from sympy.codegen.ast import ( Attribute, Declaration, Node, String, Token, Type, none, FunctionCall, CodeBlock ) from sympy.core.basic import Basic from sympy.core.containers import Tuple from sympy.core.sympify import sympify void = Type('void') ...
52755b8a4cf6be3268f03b44d368a96ba644b027b9957393febd7a1790725b84
import math from sympy.sets.sets import Interval from sympy.calculus.singularities import is_increasing, is_decreasing from sympy.codegen.rewriting import Optimization from sympy.core.function import UndefinedFunction """ This module collects classes useful for approimate rewriting of expressions. This can be benefici...
1906f2d917dd5a3dd910d031a7d53b9c641356260b3918a99ec433fa104cdc3e
""" AST nodes specific to Fortran. The functions defined in this module allows the user to express functions such as ``dsign`` as a SymPy function for symbolic manipulation. """ from sympy.codegen.ast import ( Attribute, CodeBlock, FunctionCall, Node, none, String, Token, _mk_Tuple, Variable ) from sympy.core...
8885997a9a6fcf2d6d5f555f11fb209161e667ca59b422c58abfb4432e7f96dc
from sympy.core.function import Add, ArgumentIndexError, Function from sympy.core.power import Pow from sympy.core.singleton import S from sympy.core.sorting import default_sort_key from sympy.functions.elementary.exponential import exp, log def _logaddexp(x1, x2, *, evaluate=True): return log(Add(exp(x1, evaluat...
fe2b12401cd0ce7d712a462160417b9d52b5b026bb9fbf10a3902809e36cf1e5
from sympy.core.containers import Tuple from sympy.core.numbers import oo from sympy.core.relational import (Gt, Lt) from sympy.core.symbol import (Dummy, Symbol) from sympy.functions.elementary.complexes import Abs from sympy.logic.boolalg import And from sympy.codegen.ast import ( Assignment, AddAugmentedAssignme...
68d83eb67e8d337a66d24a9ca0d8e0c7b2d2f27ec092b91b16153549c363e1d4
from sympy.core import Tuple class List(Tuple): """Represents a (frozen) (Python) list (for code printing purposes).""" def __eq__(self, other): if isinstance(other, list): return self == List(*other) else: return self.args == other
eacd5bcba5fd8ba60d4ee0a078ef9529bba0beeeb03daa32877e9263b0122cdc
""" Classes and functions useful for rewriting expressions for optimized code generation. Some languages (or standards thereof), e.g. C99, offer specialized math functions for better performance and/or precision. Using the ``optimize`` function in this module, together with a collection of rules (represented as instan...
c0bab771489e82fdefb61503ec9c88a73cf263214182e61b977ed5f0e6bde961
""" Types used to represent a full function/module as an Abstract Syntax Tree. Most types are small, and are merely used as tokens in the AST. A tree diagram has been included below to illustrate the relationships between the AST types. AST Type Tree ------------- :: *Basic* | | CodegenAST ...
569add05ba306e6f1d47b981d45f49f74f17db9068d0268839703b8d5beb89ff
""" This module contains SymPy functions mathcin corresponding to special math functions in the C standard library (since C99, also available in C++11). The functions defined in this module allows the user to express functions such as ``expm1`` as a SymPy function for symbolic manipulation. """ from sympy.core.functi...
86ed2d0b71c542a3e9a2d08c95b93fc46f45849a3fadcea9dc98b98a8f38bbbb
""" Additional AST nodes for operations on matrices. The nodes in this module are meant to represent optimization of matrix expressions within codegen's target languages that cannot be represented by SymPy expressions. As an example, we can use :meth:`sympy.codegen.rewriting.optimize` and the ``matin_opt`` optimizatio...
e410c44a162a2af7781718166aa74de02007eed18ff9d99382f3fe5dc616548a
""" This file contains some classical ciphers and routines implementing a linear-feedback shift register (LFSR) and the Diffie-Hellman key exchange. .. warning:: This module is intended for educational purposes only. Do not use the functions in this module for real cryptographic applications. If you wish to ...
4e6081d2bc61dfc01334199b518ff674dead581ec25dc7ed8e1cbd35c1fc0aa2
from typing import Dict as tDict, Callable from sympy.core import S, Add, Expr, Basic, Mul, Pow, Rational from sympy.core.logic import fuzzy_not from sympy.logic.boolalg import Boolean from sympy.assumptions import ask, Q # type: ignore def refine(expr, assumptions=True): """ Simplify an expression using a...
4d70d722cae2d6d771b118bf5fae0da40def89db78ecf4a8f758b5ec06190f7e
""" Module to evaluate the proposition with assumptions using SAT algorithm. """ from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.assumptions.ask_generated import get_all_known_facts from sympy.assumptions.assume import global_assumptions, AppliedPredicate from sympy.assumptions.satha...
9204f439a60170898d25147ef1e2311db515e334e3e3f255eb39867e74050d32
""" Known facts in assumptions module. This module defines the facts between unary predicates in ``get_known_facts()``, and supports functions to generate the contents in ``sympy.assumptions.ask_generated`` file. """ from sympy.assumptions import Q from sympy.assumptions.assume import AppliedPredicate from sympy.core...
0a8aad131f959234b0cfe3a26b87032390169825808e0aca9d172633f098d672
""" The classes used here are for the internal use of assumptions system only and should not be used anywhere else as these do not possess the signatures common to SymPy objects. For general use of logic constructs please refer to sympy.logic classes And, Or, Not, etc. """ from itertools import combinations, product fr...
f57acd2763aea0efaff855f86714e4395587de6ae94d889817c98d4c52a4f229
from collections import defaultdict from sympy.assumptions.ask import Q from sympy.core import (Add, Mul, Pow, Number, NumberSymbol, Symbol) from sympy.core.numbers import ImaginaryUnit from sympy.functions.elementary.complexes import Abs from sympy.logic.boolalg import (Equivalent, And, Or, Implies) from sympy.matric...
234854f46260a8df2e287fbc645b220404a1a4c0adf14b2706ee43d7b0c9ed50
"""A functions module, includes all the standard functions. Combinatorial - factorial, fibonacci, harmonic, bernoulli... Elementary - hyperbolic, trigonometric, exponential, floor and ceiling, sqrt... Special - gamma, zeta,spherical harmonics... """ from sympy.functions.combinatorial.factorials import (factorial, fac...
4ceb2e900c9bce4ffa659f89ded25dbe8751b7bc349453ccb60572fb78fd30da
from sympy.core.add import Add from sympy.core.exprtools import factor_terms from sympy.core.function import expand_log, _mexpand from sympy.core.power import Pow from sympy.core.singleton import S from sympy.core.sorting import ordered from sympy.core.symbol import Dummy from sympy.functions.elementary.exponential imp...
0f0903912cc12129487e8f1d591dcbb41bbb090771be370c53140bf1a846b9fd
r""" This module is intended for solving recurrences or, in other words, difference equations. Currently supported are linear, inhomogeneous equations with polynomial or rational coefficients. The solutions are obtained among polynomials, rational functions, hypergeometric terms, or combinations of hypergeometric term...
1dc6ca68f4554ce51f0c12e732176dac992f87dd29a2810a82fef918894fa50c
from sympy.core import (Function, Pow, sympify, Expr) from sympy.core.relational import Relational from sympy.core.singleton import S from sympy.polys import Poly, decompose from sympy.utilities.misc import func_name def decompogen(f, symbol): """ Computes General functional decomposition of ``f``. Given ...
2de3a2abec02e84a7c9c6497668cd96a903b0d5f0a8a0d7da24db2cf24f73282
""" This module contains functions to: - solve a single equation for a single variable, in any domain either real or complex. - solve a single transcendental equation for a single variable in any domain either real or complex. (currently supports solving in real domain only) - solve a system of lin...
7fcacc00af2aa64095c2dbbddbdd0d50e84f941e17e4a9436037f79cae361863
""" This module contains pdsolve() and different helper functions that it uses. It is heavily inspired by the ode module and hence the basic infrastructure remains the same. **Functions in this module** These are the user functions in this module: - pdsolve() - Solves PDE's - classify_pde() - Classif...
2e7850490c83ec507d172153da350bd67a307c40b4e694edf500af80caa326ec
"""Solvers of systems of polynomial equations. """ from sympy.core import S from sympy.core.sorting import default_sort_key from sympy.polys import Poly, groebner, roots from sympy.polys.polytools import parallel_poly_from_expr from sympy.polys.polyerrors import (ComputationFailed, PolificationFailed, CoercionFail...
12b787afef706491336a17cd1c3ef28ca1453ce994c4df40b755514cebfcec19
"""Tools for solving inequalities and systems of inequalities. """ from sympy.core import Symbol, Dummy, sympify from sympy.core.exprtools import factor_terms from sympy.core.relational import Relational, Eq, Ge, Lt from sympy.sets.sets import Interval, FiniteSet, Union, Intersection from sympy.core.singleton import S...
4bb6a5274117691f536d7295901e2ff6eae4b10d91b528606460c7f0251d8e23
""" This module contain solvers for all kinds of equations: - algebraic or transcendental, use solve() - recurrence, use rsolve() - differential, use dsolve() - nonlinear (numerically), use nsolve() (you will need a good starting point) """ from sympy.core import (S, Add, Symbol, Dummy, Expr...
e5d0e043d8127e3fdd93ddd85728287a12624cef63c92f470e5fdec0c5dcb5a3
""" Discrete Fourier Transform, Number Theoretic Transform, Walsh Hadamard Transform, Mobius Transform """ from sympy.core import S, Symbol, sympify from sympy.core.function import expand_mul from sympy.core.numbers import pi, I from sympy.functions.elementary.trigonometric import sin, cos from sympy.ntheory import is...
c5e5c22f13d2a4135faca3653c61a9b94dc3f40cdfd2e474d4ea4318238000b8
""" Convolution (using **FFT**, **NTT**, **FWHT**), Subset Convolution, Covering Product, Intersecting Product """ from sympy.core import S, sympify from sympy.core.function import expand_mul from sympy.discrete.transforms import ( fft, ifft, ntt, intt, fwht, ifwht, mobius_transform, inverse_mobius_transform) ...
bce3044ef93127f32bd8838b5c5c31949152ff48457ab71eb23f5cc1dd9990c7
""" Recurrences """ from sympy.core import S, sympify from sympy.utilities.iterables import iterable from sympy.utilities.misc import as_int def linrec(coeffs, init, n): r""" Evaluation of univariate linear recurrences of homogeneous type having coefficients independent of the recurrence variable. P...
6d71aa3e22cddf1e0d02c33e6472893f114ee9163b94365472409aac8383122d
from .cartan_type import Standard_Cartan from sympy.core.backend import eye class TypeC(Standard_Cartan): def __new__(cls, n): if n < 3: raise ValueError("n cannot be less than 3") return Standard_Cartan.__new__(cls, "C", n) def dimension(self): """Dimension of the vector...
51ff90cc8fba6d125e23dd6cb461ec89eb249f004455822365a88d3fed9b2226
from .cartan_type import Standard_Cartan from sympy.core.backend import eye, Rational class TypeE(Standard_Cartan): def __new__(cls, n): if n < 6 or n > 8: raise ValueError("Invalid value of n") return Standard_Cartan.__new__(cls, "E", n) def dimension(self): """Dimension...
e88229b83ccb0a711fc57b670555e8a612ee6a26df70ef3d548dc55187ac7f30
from sympy.core import Basic class CartanType_generator(Basic): """ Constructor for actually creating things """ def __call__(self, *args): c = args[0] if isinstance(c, list): letter, n = c[0], int(c[1]) elif isinstance(c, str): letter, n = c[0], int(c[1...
e74c5d72b79cd67145b725163a63f6426f595b5ce96eb8306f3fd83caa79e46a
from .cartan_type import Standard_Cartan from sympy.core.backend import eye class TypeB(Standard_Cartan): def __new__(cls, n): if n < 2: raise ValueError("n cannot be less than 2") return Standard_Cartan.__new__(cls, "B", n) def dimension(self): """Dimension of the vector ...
9794942649e3d712e0c1154cb8eb159b06dcc58d95e8f539f6306db2cca5287e
from sympy.liealgebras.cartan_type import Standard_Cartan from sympy.core.backend import eye class TypeA(Standard_Cartan): """ This class contains the information about the A series of simple Lie algebras. ==== """ def __new__(cls, n): if n < 1: raise ValueError("n cannot ...
f42c0bd098f76614e6e34f91a4c7b445b76d6cec494ba2b399287d7d361f4392
from .cartan_type import CartanType from sympy.core.backend import Basic class RootSystem(Basic): """Represent the root system of a simple Lie algebra Every simple Lie algebra has a unique root system. To find the root system, we first consider the Cartan subalgebra of g, which is the maximal abelian...
1e66d978ec7fd7d41acc55c7fd2621b8617d02d1c394b58af0b462a823a34970
# -*- coding: utf-8 -*- from .cartan_type import CartanType from mpmath import fac from sympy.core.backend import Matrix, eye, Rational, Basic, igcd class WeylGroup(Basic): """ For each semisimple Lie group, we have a Weyl group. It is a subgroup of the isometry group of the root system. Specifically, ...
adb9d254606cd26b58f2d4718eea2e9d219e5cf07fe944af92fdb2b0fc89f719
""" Singularities ============= This module implements algorithms for finding singularities for a function and identifying types of functions. The differential calculus methods in this module include methods to identify the following function types in the given ``Interval``: - Increasing - Strictly Increasing - Decre...
d10ac70fd4d82a5499b8ef1dae75376d4149ad2bbcbf94a772ab6445258b8c63
""" This module implements a method to find Euler-Lagrange Equations for given Lagrangian. """ from itertools import combinations_with_replacement from sympy.core.function import (Derivative, Function, diff) from sympy.core.relational import Eq from sympy.core.singleton import S from sympy.core.symbol import Symbol fro...
b93e60ae15dbf726a6c18c20a57b08089d0a9aebd5e0588b6da74bda162f5f45
""" Finite difference weights ========================= This module implements an algorithm for efficient generation of finite difference weights for ordinary differentials of functions for derivatives from 0 (interpolation) up to arbitrary order. The core algorithm is provided in the finite difference weight generat...
3b0889cee9315aaddbea226986fcd104c2399e23f1018c5a5004208a7ad56d5a
from sympy.functions.elementary.piecewise import Piecewise from sympy.polys.polytools import lcm_list from sympy.series.limits import limit from sympy.series.order import Order from sympy.core import Add, Mul, Pow, S from sympy.core.basic import Basic from sympy.core.expr import AtomicExpr, Expr from sympy.core.functio...
b2f878c4321af271a90de1f84de45be3d806f2688cbd7a42cc46ab6e8af9f041
from sympy.tensor import Indexed from sympy.core.containers import Tuple from sympy.core.symbol import Dummy from sympy.core.sympify import sympify from sympy.integrals.integrals import Integral class IndexedIntegral(Integral): """ Experimental class to test integration by indexed variables. Usage is ana...
06b7ad56e3a3ab6324fce4724b985c3514dd2c67daaecc9903b3b6b05979f392
from sympy.core.basic import Basic new = Basic.__new__ def assoc(d, k, v): d = d.copy() d[k] = v return d basic_fns = {'op': type, 'new': Basic.__new__, 'leaf': lambda x: not isinstance(x, Basic) or x.is_Atom, 'children': lambda x: x.args} expr_fns = assoc(basic_fn...
b9fe9515d5e9b5940d0a4b3227be4685a483ca67aa64f9644afdeedce7a809ac
""" module for generating C, C++, Fortran77, Fortran90, Julia, Rust and Octave/Matlab routines that evaluate SymPy expressions. This module is work in progress. Only the milestones with a '+' character in the list below have been completed. --- How is sympy.utilities.codegen different from sympy.printing.ccode? --- W...
6afdd108118a37ac56e929e142fe1163b4aded027c3859665e9b902f568b680f
"""Module for compiling codegen output, and wrap the binary for use in python. .. note:: To use the autowrap module it must first be imported >>> from sympy.utilities.autowrap import autowrap This module provides a common interface for different external backends, such as f2py, fwrap, Cython, SWIG(?) etc. (Curren...
754fe07e4bf36d118637c8b714f68a7983e3938ba26fcf4a89116120f6b33903
""" This module adds several functions for interactive source code inspection. """ from sympy.utilities.decorator import deprecated import inspect @deprecated(useinstead="?? in IPython/Jupyter or inspect.getsource", issue=14905, deprecated_since_version="1.3") def source(object): """ Prints the source code o...
f848bc1b8456f90b9b84c9b0bbd4d000f751df0962127251faf335783900b475
"""This module contains some general purpose utilities that are used across SymPy. """ from .iterables import (flatten, group, take, subsets, variations, numbered_symbols, cartes, capture, dict_merge, prefixes, postfixes, sift, topological_sort, unflatten, has_dups, has_variety, reshape, rotations) from .m...
dedafc0d94b11e3e08fa5931a6038b1dc498a470656891d189d1ec26fb018c25
""" This module provides convenient functions to transform SymPy expressions to lambda functions which can be used to calculate numerical values very fast. """ from typing import Any, Dict as tDict, Iterable, Union as tUnion, TYPE_CHECKING import builtins import inspect import keyword import textwrap import linecache...
8edfa128bd318719c324323d0b6217b47fd081862d7eaf5f5fd909dc4ee26a78
""" pkgdata is a simple, extensible way for a package to acquire data file resources. The getResource function is equivalent to the standard idioms, such as the following minimal implementation:: import sys, os def getResource(identifier, pkgname=__name__): pkgpath = os.path.dirname(sys.modules[pkgna...
5f0660333f2e489088357f20bd743a21449b2265c9364030b36cb93e25452ed4
""" Algorithms and classes to support enumerative combinatorics. Currently just multiset partitions, but more could be added. Terminology (following Knuth, algorithm 7.1.2.5M TAOCP) *multiset* aaabbcccc has a *partition* aaabc | bccc The submultisets, aaabc and bccc of the partition are called *parts*, or sometimes ...