hash
stringlengths
64
64
content
stringlengths
0
1.51M
b5d3f9b0de68de80dcf6fc2c986ef235bbb5a1766555929fcf50910822e331ee
""" This module implements Holonomic Functions and various operations on them. """ from sympy import (Symbol, S, Dummy, Order, rf, I, solve, limit, Float, nsimplify, gamma) from sympy.core.compatibility import ordered from sympy.core.numbers import NaN, Infinity, NegativeInfinity from sympy.core.sympify import sym...
fe93534f523d7f13541183b40218eb96bef70c846670f331ec85f07422fe7e7f
from sympy.printing import pycode, ccode, fcode from sympy.external import import_module from sympy.utilities.decorator import doctest_depends_on lfortran = import_module('lfortran') cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']}) if lfortran: from sympy.parsing.fortran.fortran_parse...
9f484e86e5b3a6a33e8830c680bce6203ce814969c99847d075b5d44ef020abd
import re from sympy import sympify, Sum, product, sin, cos class MaximaHelpers: def maxima_expand(expr): return expr.expand() def maxima_float(expr): return expr.evalf() def maxima_trigexpand(expr): return expr.expand(trig=True) def maxima_sum(a1, a2, a3, a4): retur...
e49e508a62209a00cb85ce309909b9dca9458628ba16659efec8aeb1dc99ddda
from typing import Any, Dict, Tuple from itertools import product import re from sympy import sympify def mathematica(s, additional_translations=None): ''' Users can add their own translation dictionary. variable-length argument needs '*' character. Examples ======== >>> from sympy.parsing....
3efeb94e5a4f41a3b192474bf1946df6bd7a3bd5fb8519526d1b6092ec8e68cd
"""Transform a string with Python-like source code into SymPy expression. """ from tokenize import (generate_tokens, untokenize, TokenError, NUMBER, STRING, NAME, OP, ENDMARKER, ERRORTOKEN, NEWLINE) from keyword import iskeyword import ast import unicodedata from sympy.core.compatibility import exec_, StringIO,...
78de22bd4bab719a73c8f378de4a01049744da58805a508cc78f8d1b937f89ad
""" This module implements the functionality to take any Python expression as a string and fix all numbers and other things before evaluating it, thus 1/2 returns Integer(1)/Integer(2) We use the ast module for this. It is well documented at docs.python.org. Some tips to understand how this works: use dump() to ge...
bc9479a440521bbbfd783b0c66e37b7d072ac153cc8501590c578df322ee05fa
# -*- coding: utf-8 -*- r""" Wigner, Clebsch-Gordan, Racah, and Gaunt coefficients Collection of functions for calculating Wigner 3j, 6j, 9j, Clebsch-Gordan, Racah as well as Gaunt coefficients exactly, all evaluating to a rational number times the square root of a rational number [Rasch03]_. Please see the descripti...
7ea75b019ce2e829725a2b807ec5689caf47665583ea951b8a115c5dd4f7ed96
""" This module implements Pauli algebra by subclassing Symbol. Only algebraic properties of Pauli matrices are used (we don't use the Matrix class). See the documentation to the class Pauli for examples. References ~~~~~~~~~~ .. [1] https://en.wikipedia.org/wiki/Pauli_matrices """ from sympy import Symbol, I, Mul, ...
76b203fc17abe71376c95ce0b72b831b897ad997ce954543bb2060ae6e98cfd9
from sympy.core import S, pi, Rational from sympy.functions import assoc_laguerre, sqrt, exp, factorial, factorial2 def R_nl(n, l, nu, r): """ Returns the radial wavefunction R_{nl} for a 3d isotropic harmonic oscillator. ``n`` the "nodal" quantum number. Corresponds to the number of nodes i...
e2ae13b95c239fee8da86232b706d7152151f976d6f020b9cbe8be1768c5c444
from sympy.core import S, pi, Rational from sympy.functions import hermite, sqrt, exp, factorial, Abs from sympy.physics.quantum.constants import hbar def psi_n(n, x, m, omega): """ Returns the wavefunction psi_{n} for the One-dimensional harmonic oscillator. ``n`` the "nodal" quantum number. Co...
7001161b2b42eaa29b2a0b6e17f823cf3aa197e2515b5ba616707e0fc6632511
from sympy import factorial, sqrt, exp, S, assoc_laguerre, Float from sympy.functions.special.spherical_harmonics import Ynm def R_nl(n, l, r, Z=1): """ Returns the Hydrogen radial wavefunction R_{nl}. n, l quantum numbers 'n' and 'l' r radial coordinate Z atomic number (1...
a90e85b4000c2d8a000f2db7b81e094c1375d053debdb905422309b14831645f
"""Known matrices related to physics""" from sympy import Matrix, I, pi, sqrt from sympy.functions import exp def msigma(i): r"""Returns a Pauli matrix `\sigma_i` with `i=1,2,3` References ========== .. [1] https://en.wikipedia.org/wiki/Pauli_matrices Examples ======== >>> from sympy....
913ad06ea27316f21b8f36af80475fdd8a47110f53a3870837fae454eb8cd317
""" Second quantization operators and states for bosons. This follow the formulation of Fetter and Welecka, "Quantum Theory of Many-Particle Systems." """ from collections import defaultdict from sympy import (Add, Basic, cacheit, Dummy, Expr, Function, I, KroneckerDelta, Mul, Pow, S, sqrt, Symbol,...
b591189259f58dd32da44b80182dc3d3d8b90ad90459daafa78385a0b03aeba4
from sympy import sqrt, exp, S, pi, I from sympy.physics.quantum.constants import hbar def wavefunction(n, x): """ Returns the wavefunction for particle on ring. n is the quantum number, x is the angle, here n can be positive as well as negative which can be used to describe the direction of moti...
6a50e5a3944f207ecacdec66eb33347316295c37b2dd124012bf3888942558f9
""" This module defines tensors with abstract index notation. The abstract index notation has been first formalized by Penrose. Tensor indices are formal objects, with a tensor type; there is no notion of index range, it is only possible to assign the dimension, used to trace the Kronecker delta; the dimension can be...
3987b0ceb1343a8f9a90d50806d975e8dfc90f57431c7d2b58391d44b52a3b6e
"""Module with functions operating on IndexedBase, Indexed and Idx objects - Check shape conformance - Determine indices in resulting expression etc. Methods in this module could be implemented by calling methods on Expr objects instead. When things stabilize this could be a useful refactori...
854ed45e07d6e0369b8a48bd1a5ed3d9b119888e5de898630b6c62265b035cb6
r"""Module that defines indexed objects The classes ``IndexedBase``, ``Indexed``, and ``Idx`` represent a matrix element ``M[i, j]`` as in the following diagram:: 1) The Indexed class represents the entire indexed object. | ___|___ ' ' M[i, j]...
50cfca40d38969eb39bed25153b6dab15e0e8db5f102ea13d567de37e923677f
from contextlib import contextmanager from threading import local from sympy.core.function import expand_mul from sympy.simplify.simplify import dotprodsimp as _dotprodsimp class DotProdSimpState(local): def __init__(self): self.state = None _dotprodsimp_state = DotProdSimpState() @contextmanager def d...
e090949f6d3e8cf5b069933e13d626c3c2f8c0cccd111a2cf7c528f3c13afbf3
from types import FunctionType from sympy.core.numbers import Float, Integer from sympy.core.singleton import S from sympy.core.symbol import uniquely_named_symbol from sympy.polys import PurePoly, cancel from sympy.simplify.simplify import (simplify as _simplify, dotprodsimp as _dotprodsimp) from sympy import sym...
a654e3d35574351de454d03e973ac01ea57bf6455bd9277cdd72507792294a49
"""A module that handles matrices. Includes functions for fast creating matrices like zero, one/eye, random matrix, etc. """ from .common import ShapeError, NonSquareMatrixError from .dense import ( GramSchmidt, casoratian, diag, eye, hessian, jordan_cell, list2numpy, matrix2numpy, matrix_multiply_elementwise,...
7d3974fbc2c191950835d57fe93555841aa5e4cd0a22941e38a7dd70c68df7a6
from mpmath.matrices.matrices import _matrix from sympy.core import Basic, Dict, Integer, Tuple from sympy.core.cache import cacheit from sympy.core.sympify import converter as sympify_converter, _sympify from sympy.matrices.dense import DenseMatrix from sympy.matrices.expressions import MatrixExpr from sympy.matrices...
eac7c416b2349ce03ddb0716c8e833cb2a0695a68dca2c75eeb870a4c21e57e6
""" Basic methods common to all matrices to be used when creating more advanced matrices (e.g., matrices over rings, etc.). """ from sympy.core.logic import FuzzyBool from collections import defaultdict from inspect import isfunction from sympy.assumptions.refine import refine from sympy.core import SympifyError, Ad...
2a809dcfbf8dde12479ae4166287a55599503c9072ef9eda161dff3cd2ff529c
import random from sympy.core import SympifyError, Add from sympy.core.basic import Basic from sympy.core.compatibility import is_sequence, reduce from sympy.core.expr import Expr from sympy.core.singleton import S from sympy.core.symbol import Symbol from sympy.core.sympify import sympify, _sympify from sympy.functio...
70eee23da3bbfffbd639649ec8f01869ad9db7184d77db940716161bf3894382
from sympy.core.function import expand_mul from sympy.core.symbol import Dummy, uniquely_named_symbol, symbols from sympy.utilities.iterables import numbered_symbols from .common import ShapeError, NonSquareMatrixError, NonInvertibleMatrixError from .eigen import _fuzzy_positive_definite from .utilities import _get_in...
211c087102e04a21a48988837382a5ab7016bd6fd14595bdcefd935e101db79a
from collections import defaultdict from sympy.core import SympifyError, Add from sympy.core.compatibility import Callable, as_int, is_sequence, reduce from sympy.core.containers import Dict from sympy.core.expr import Expr from sympy.core.singleton import S from sympy.core.sympify import _sympify from sympy.functions...
4088134ebd4d4d80b57d2238d4da3019f3d11d42d09cfd10bd81cbc7772b769e
import mpmath as mp from sympy.core.add import Add from sympy.core.basic import Basic from sympy.core.compatibility import ( Callable, NotIterable, as_int, is_sequence) from sympy.core.decorators import deprecated from sympy.core.expr import Expr from sympy.core.power import Pow from sympy.core.singleton import S ...
baad9bf7fd06104b405ce00dfeacbfd755ed7fa9fb9db734e5b7239327e51a8e
from sympy.core import S from sympy.core.relational import Eq, Ne from sympy.logic.boolalg import BooleanFunction from sympy.utilities.misc import func_name class Contains(BooleanFunction): """ Asserts that x is an element of the set S Examples ======== >>> from sympy import Symbol, Integer, S ...
722921ddef28a058ce2c78601cf647de5ddfb1149f56c0fff689116c5c536590
from sympy.core import Basic, Integer import operator class OmegaPower(Basic): """ Represents ordinal exponential and multiplication terms one of the building blocks of the Ordinal class. In OmegaPower(a, b) a represents exponent and b represents multiplicity. """ def __new__(cls, a, b): ...
d81651ea31a5160f770e111ad5cf0a5eb544abd72d68c18ca80c77355d63cb33
from sympy.core import Expr from sympy.core.decorators import call_highest_priority, _sympifyit from sympy.sets import ImageSet from sympy.sets.sets import set_add, set_sub, set_mul, set_div, set_pow, set_function class SetExpr(Expr): """An expression that can take on values of a set >>> from sympy import Int...
569b6bc212c937d7deee517153e7b28dd640d60d2d12ca36a9b6a2db85b3be33
from sympy.core.decorators import _sympifyit from sympy.core.parameters import global_parameters from sympy.core.logic import fuzzy_bool from sympy.core.singleton import S from sympy.core.sympify import _sympify from .sets import Set class PowerSet(Set): r"""A symbolic object representing a power set. Param...
1c38b92d26940047d072fdaa324d0cf08830c556a42c5b9df17ece352cdd2959
from functools import reduce from sympy.core.basic import Basic from sympy.core.containers import Tuple from sympy.core.expr import Expr from sympy.core.function import Lambda from sympy.core.logic import fuzzy_not, fuzzy_or, fuzzy_and from sympy.core.numbers import oo, Integer from sympy.core.relational import Eq fro...
b0e9ff42d0280165bfd77b4433ec8e6a57670e84e62e91c8cfb1d0fd1d03cf05
from typing import Optional from collections import defaultdict import inspect from sympy.core.basic import Basic from sympy.core.compatibility import iterable, ordered, reduce from sympy.core.containers import Tuple from sympy.core.decorators import (deprecated, sympify_method_args, sympify_return) from sympy.co...
98274c434252a326212296b7243e25950fb091101ffc4d772b9edfaca5758a6c
from sympy import S from sympy.core.basic import Basic from sympy.core.containers import Tuple from sympy.core.function import Lambda from sympy.core.logic import fuzzy_bool from sympy.core.relational import Eq from sympy.core.symbol import Dummy from sympy.core.sympify import _sympify from sympy.logic.boolalg import A...
b283461565979f7a8ada5ed6b3e51ebe22ed88a0a025a2f61709581e66642c96
"""Implicit plotting module for SymPy The module implements a data series called ImplicitSeries which is used by ``Plot`` class to plot implicit plots for different backends. The module, by default, implements plotting using interval arithmetic. It switches to a fall back algorithm if the expression cannot be plotted ...
ac17818c5e11eb78346307641f03f997ad1735eeb839d3f284b389663acd1ee1
"""Plotting module for Sympy. A plot is represented by the ``Plot`` class that contains a reference to the backend and a list of the data series to be plotted. The data series are instances of classes meant to simplify getting points and meshes from sympy expressions. ``plot_backends`` is a dictionary with all the bac...
886501fa96f3ff825fbccde9823278d51eb00fd4cc4c562df1e234dabd7bef64
from sympy.core.numbers import Float from sympy.core.symbol import Dummy from sympy.utilities.lambdify import lambdify import math def is_valid(x): """Check if a floating point number is valid""" if x is None: return False if isinstance(x, complex): return False return not math.isinf(...
94978c7437afeced615b702ffe6c722a544243ef16f05f8cdc7cb4a4cca9f122
""" rewrite of lambdify - This stuff is not stable at all. It is for internal use in the new plotting module. It may (will! see the Q'n'A in the source) be rewritten. It's completely self contained. Especially it does not use lambdarepr. It does not aim to replace the current lambdify. Most importantly it will never...
db7b687551b807b3bc5722af5758922d49d686a29f3ef8aa79f11303341186ad
from sympy import (S, Symbol, Interval, exp, Or, symbols, Eq, cos, And, Tuple, integrate, oo, sin, Sum, Basic, Indexed, DiracDelta, Lambda, log, pi, FallingFactorial, Rational, Matrix) from sympy.stats import (Die, Normal, Exponential, FiniteRV, P, E, H, variance, density, given, independent, de...
ed6cc7ecc95712c3d3fc94bf391056d3bdb82d8bb5bb1544370fef9ca8e6dfe0
from sympy import (FiniteSet, S, Symbol, sqrt, nan, beta, Rational, symbols, simplify, Eq, cos, And, Tuple, Or, Dict, sympify, binomial, cancel, exp, I, Piecewise, Sum, Dummy) from sympy.external import import_module from sympy.matrices import Matrix from sympy.stats import (Discre...
5c88158a0add9c53c6491e6db8e4151d6ff13ce51e78479e75c932fae12deac0
from sympy import (S, symbols, FiniteSet, Eq, Matrix, MatrixSymbol, Float, And, ImmutableMatrix, Ne, Lt, Le, Gt, Ge, exp, Not, Rational, Lambda, erf, Piecewise, factorial, Interval, oo, Contains, sqrt, pi, ceiling, gamma, lowergamma, Sum, Range, Tuple, ImmutableD...
dd27846b703170faadd314818ab8835ce9383b611d78066783498115a703b36b
from sympy import (S, Symbol, Sum, I, lambdify, re, im, log, simplify, sqrt, zeta, pi, besseli, Dummy, oo, Piecewise, Rational, beta, floor, FiniteSet) from sympy.core.relational import Eq, Ne from sympy.functions.elementary.exponential import exp from sympy.logic.boolalg import Or...
f0ae326421a1123495cee234a343af462a81f8875c127aca3c03e1017ef17eb1
from sympy import E as e from sympy import (Symbol, Abs, exp, expint, S, pi, simplify, Interval, erf, erfc, Ne, EulerGamma, Eq, log, lowergamma, uppergamma, symbols, sqrt, And, gamma, beta, Piecewise, Integral, sin, cos, tan, sinh, cosh, besseli, floor, expand_fu...
f870182e0fce9d3f9550f166d815f59160ad24f739a952224a29e195ea7f7272
from typing import Dict, Tuple from sympy.ntheory import qs from sympy.ntheory.qs import SievePolynomial, \ _generate_factor_base, _initialize_first_polynomial, _initialize_ith_poly, \ _gen_sieve_array, _check_smoothness, _trial_division_stage, _gauss_mod_2, \ _build_matrix, _find_factor assert qs(1000920...
0146f9c94e162c2f6518306b2fd3940a0264672df51e30c06ff0a617ddc1e2f9
from sympy import Symbol, O, Add x = Symbol('x') l = list(x**i for i in range(1000)) l.append(O(x**1001)) def timeit_order_1x(): _ = Add(*l)
f8a0141306160db054b547a1d7be8f5747fcad75a138e2e98226435eead1c884
from sympy import Symbol, limit, oo x = Symbol('x') def timeit_limit_1x(): limit(1/x, x, oo)
ca4dda5ce1181b55c620f57a70290c6dda7be8ee1b95bc6d77d9f14866211266
from sympy import (Symbol, Rational, Order, exp, ln, log, nan, oo, O, pi, I, S, Integral, sin, cos, sqrt, conjugate, expand, transpose, symbols, Function, Add) from sympy.core.expr import unchanged from sympy.testing.pytest import raises from sympy.abc import w, x, y, z def test_caching_bug(): #needs to b...
60ebfd19c9ca44d5ee6182fa7cb285980482577707b252a2b873e92610e4cfa1
from itertools import product as cartes from sympy import ( limit, exp, oo, log, sqrt, Limit, sin, floor, cos, ceiling, atan, Abs, gamma, Symbol, S, pi, Integral, Rational, I, tan, cot, integrate, Sum, sign, Function, subfactorial, symbols, binomial, simplify, frac, Float, sec, zoo, fresnelc, fresnels,...
5dbc1babb6f47b32c62c7a9887e5631f8d85acc0f510e70f0424924262d2d49c
from sympy import ( Abs, acos, Add, asin, atan, Basic, binomial, besselsimp, cos, cosh, count_ops, csch, diff, E, Eq, erf, exp, exp_polar, expand, expand_multinomial, factor, factorial, Float, Function, gamma, GoldenRatio, hyper, hypersimp, I, Integral, integrate, KroneckerDelta, log, logcombine, Lt...
758aea82970eecfedbf649b4e89f686a58180219aa23d302cf3eff68de809678
from sympy.core.symbol import symbols from sympy.printing import ccode from sympy.codegen.ast import Declaration, Variable, float64, int64, String, CodeBlock from sympy.codegen.cnodes import ( alignof, CommaOperator, goto, Label, PreDecrement, PostDecrement, PreIncrement, PostIncrement, sizeof, union, struct ) ...
40d857ffee34d0b4bc123a1a787c9f0aa1d5f4bda2fb90296f9629e7727b87c5
import os import tempfile from sympy import Symbol, symbols from sympy.codegen.ast import ( Assignment, Print, Declaration, FunctionDefinition, Return, real, FunctionCall, Variable, Element, integer ) from sympy.codegen.fnodes import ( allocatable, ArrayConstructor, isign, dsign, cmplx, kind, literal_dp, ...
52e1a1b8611ebc2d8a1287781a5e53d1d18557ddd40bd49d1b6ba1af6579242a
from sympy import symbols, IndexedBase, Identity, cos, Inverse from sympy.codegen.array_utils import (CodegenArrayContraction, CodegenArrayTensorProduct, CodegenArrayDiagonal, CodegenArrayPermuteDims, CodegenArrayElementwiseAdd, ...
625207fcc654bbffdd851fcbce0260f48b61d9de0097e021a3f8238c03f6fb60
from typing import Tuple from sympy.core.add import Add from sympy.core.basic import sympify, cacheit from sympy.core.expr import Expr from sympy.core.function import Function, ArgumentIndexError, PoleError, expand_mul from sympy.core.logic import fuzzy_not, fuzzy_or, FuzzyBool from sympy.core.numbers import igcdex, R...
cfaa9613f01e2e5b1aef3e5f1acbac3bbfe16722ec448c7a68a13e870fa44656
from sympy import Basic, Expr from sympy.core import Add, S from sympy.core.evalf import get_integer_part, PrecisionExhausted from sympy.core.function import Function from sympy.core.logic import fuzzy_or from sympy.core.numbers import Integer from sympy.core.relational import Gt, Lt, Ge, Le, Relational, is_eq from sy...
cd32c3d3ea0d76fffd1d6be19b85da79ba2f0dfb362c52c0fe5d2432482da738
from sympy.core import S, Add, Mul, sympify, Symbol, Dummy, Basic from sympy.core.expr import Expr from sympy.core.exprtools import factor_terms from sympy.core.function import (Function, Derivative, ArgumentIndexError, AppliedUndef) from sympy.core.logic import fuzzy_not, fuzzy_or from sympy.core.numbers import pi...
bf1d3e703df2d42984c619225fc6d481066d647dd6b612926ee025bee321f3f6
from sympy import zeros, eye, Symbol, solve_linear_system N = 8 M = zeros(N, N + 1) M[:, :N] = eye(N) S = [Symbol('A%i' % i) for i in range(N)] def timeit_linsolve_trivial(): solve_linear_system(M, *S)
532c7d2bf2c02f83668f70b97c35d8185e5ec7b7b800c69ddf2f74970c871763
from sympy.core.add import Add from sympy.core.assumptions import check_assumptions from sympy.core.containers import Tuple from sympy.core.compatibility import as_int, is_sequence, ordered from sympy.core.exprtools import factor_terms from sympy.core.function import _mexpand from sympy.core.mul import Mul from sympy.c...
b68d8c103b32ec71754316ab9174da06dd47314332292c4cc359b03d423cb6a3
r""" This module contains :py:meth:`~sympy.solvers.ode.dsolve` and different helper functions that it uses. :py:meth:`~sympy.solvers.ode.dsolve` solves ordinary differential equations. See the docstring on the various functions for their uses. Note that partial differential equations support is in ``pde.py``. Note t...
059bbfe7cfbd9f3f42aee7d6b1d020aec85ce3d2de28b591f6136f29b57e47c1
# # This is the module for ODE solver classes for single ODEs. # import typing if typing.TYPE_CHECKING: from typing import ClassVar from typing import Dict, Type from typing import Iterator, List, Optional from sympy.core import S from sympy.core.exprtools import factor_terms from sympy.core.expr import Expr fr...
89011420e21bf22ef019fa73f05120029ec8a0bb90964a68a8eb9103b4907b33
from sympy.core import Add, Mul, S from sympy.core.containers import Tuple from sympy.core.compatibility import iterable from sympy.core.exprtools import factor_terms from sympy.core.numbers import I from sympy.core.relational import Eq, Equality from sympy.core.symbol import Dummy, Symbol from sympy.core.function impo...
7397f81dacb7a010a688bc61ff1de901dda228bdcae11db0bf39e98c9962faae
from sympy.core import S, Pow from sympy.core.compatibility import iterable, is_sequence from sympy.core.function import (Derivative, AppliedUndef, diff) from sympy.core.relational import Equality, Eq from sympy.core.symbol import Dummy from sympy.core.sympify import sympify from sympy.logic.boolalg import BooleanAtom...
3086932115400a18dc1c883ba5e79dca9d695c2a88412772fa08cc8a923fb86d
from sympy.core.containers import Tuple from sympy.core.function import (Function, Lambda, nfloat, diff) from sympy.core.mod import Mod from sympy.core.numbers import (E, I, Rational, oo, pi) from sympy.core.relational import (Eq, Gt, Ne) from sympy.core.singleton import S from sympy.core.symbol import (Dummy, Symb...
866dccd757c8ebcb6e7ad880143ef70296b1ab78adff059d1e2d3f0b77369c37
from sympy import ( Abs, And, Derivative, Dummy, Eq, Float, Function, Gt, I, Integral, LambertW, Lt, Matrix, Or, Poly, Q, Rational, S, Symbol, Ne, Wild, acos, asin, atan, atanh, binomial, cos, cosh, diff, erf, erfinv, erfc, erfcinv, exp, im, log, pi, re, sec, sin, sinh, solve, solve_linear, sqrt, ss...
4f420c79d77107823f1e85187e95b29dbf1473fa3b71d66f6fcf834a4457c9a7
"""Tests for solvers of systems of polynomial equations. """ from sympy import (flatten, I, Integer, Poly, QQ, Rational, S, sqrt, solve, symbols) from sympy.abc import x, y, z from sympy.polys import PolynomialError from sympy.solvers.polysys import (solve_poly_system, solve_triangulated, solve_biquadratic, So...
1b52377099192d04dcb64399e8b7023c7514204f0357c321c1b0d6eceb3494c5
""" If the arbitrary constant class from issue 4435 is ever implemented, this should serve as a set of test cases. """ from sympy import (acos, cos, cosh, Eq, exp, Function, I, Integral, log, Pow, S, sin, sinh, sqrt, Symbol) from sympy.solvers.ode.ode import constantsimp, constant_renumber from symp...
38bdfc8fd6be75aac11ef1e1eb03fa8bdcb1324dd3943b7642876ed08f7fb181
from sympy import (Add, Matrix, Mul, S, symbols, Eq, pi, factorint, oo, powsimp, Rational) from sympy.core.function import _mexpand from sympy.core.compatibility import ordered from sympy.functions.elementary.trigonometric import sin from sympy.solvers.diophantine import diophantine from sympy.solver...
e7f357e266f6b0668e609f7dc40191f88b5f20efdc583c7beb210cfd99f6c3c8
from sympy import (acos, acosh, atan, cos, Derivative, diff, Dummy, Eq, Ne, exp, Function, I, Integral, LambertW, log, O, pi, Rational, rootof, S, sin, sqrt, Subs, Symbol, tan, asin, sinh, Piecewise, symbols, Poly, sec, re, im, atan2, collect, hyper) from sympy.solvers.ode import (classify_ode, homogen...
4fa13921ec408206d35251757cd4e21c3f18772b8308814d6644dc81973859b4
from sympy import (cos, Derivative, diff, Eq, erf, erfi, exp, Function, I, Integral, log, pi, Rational, sin, sqrt, Symbol, symbols, Ei) from sympy.solvers.ode.subscheck import checkodesol, checksysodesol from sympy.functions import besselj, bessely from sympy.testing.pytest import raises, slow C0, C1, C2, ...
d7b1149b4ed9d394eda3624f015c3f0b9a85f3115b779905db3871b24b029be7
# # The main tests for the code in single.py are currently located in # sympy/solvers/tests/test_ode.py # r""" This File contains test functions for the individual hints used for solving ODEs. Examples of each solver will be returned by _get_examples_ode_sol_name_of_solver. Examples should have a key 'XFAIL' which st...
e5d116382d4a7851b4104d64ee2bdae439b2dd6f61214e224f3735864d441147
from sympy import (symbols, Symbol, diff, Function, Derivative, Matrix, Rational, S, I, Eq, sqrt, Mul, pi) from sympy.core.containers import Tuple from sympy.functions import exp, cos, sin, log, tan, Ci, Si, erf, erfi from sympy.matrices import dotprodsimp, NonSquareMatrixError from sympy.solvers.ode...
101942ad18e09671d75c8042eac7220930547cae4b083a1c1c06ca975fc35c94
""" Generic SymPy-Independent Strategies """ from sympy.core.compatibility import get_function_name def identity(x): yield x def exhaust(brule): """ Apply a branching rule repeatedly until it has no effect """ def exhaust_brl(expr): seen = {expr} for nexpr in brule(expr): if ne...
0ec4bb248f9044ebaac27d92de4707942a8879f016389443d008553a6b2293e3
from .core import exhaust, multiplex from .traverse import top_down def canon(*rules): """ Strategy for canonicalization Apply each branching rule in a top-down fashion through the tree. Multiplex through all branching rule traversals Keep doing this until there is no change. """ return exhaus...
a268df61feefc60d4c3b876e42c3a3a019a4c6c8c0bb59b68f49a1fa49b13178
""" Branching Strategies to Traverse a Tree """ from itertools import product from sympy.strategies.util import basic_fns from .core import chain, identity, do_one def top_down(brule, fns=basic_fns): """ Apply a rule down a tree running it on the top nodes first """ return chain(do_one(brule, identity), ...
8048cd29325fa56bea08bc3f6b5b50c8496dce90ab8e9edfc0a9a1a635a3435f
from sympy.strategies.branch.tools import canon from sympy import Basic def posdec(x): if isinstance(x, int) and x > 0: yield x-1 else: yield x def branch5(x): if isinstance(x, int): if 0 < x < 5: yield x-1 elif 5 < x < 10: yield x+1 elif x ...
a8ba3a1ae0779389faf3814ed9e115374e183daafed6859dfa4c37ad4bc03654
from sympy.strategies.branch.core import (exhaust, debug, multiplex, condition, notempty, chain, onaction, sfilter, yieldify, do_one, identity) from sympy.core.compatibility import get_function_name def posdec(x): if x > 0: yield x-1 else: yield x def branch5(x): if 0 < x <...
71ab309f0a2e950f01c0eb90b592f58f825b096a8ce328a84000493f880a7732
""" Tests from Michael Wester's 1999 paper "Review of CAS mathematical capabilities". http://www.math.unm.edu/~wester/cas/book/Wester.pdf See also http://math.unm.edu/~wester/cas_review.html for detailed output of each tested system. """ from sympy import (Rational, symbols, Dummy, factorial, sqrt, log, exp, oo, zoo,...
0fe1f22a86ccda6825612845a2d2be6cf269088172e777f6ce1f1018edf5a962
from textwrap import dedent from itertools import islice, product from sympy import ( symbols, Integer, Integral, Tuple, Dummy, Basic, default_sort_key, Matrix, factorial, true) from sympy.combinatorics import RGS_enum, RGS_unrank, Permutation from sympy.core.compatibility import iterable from sympy.utilities....
dd5d70a1d1b2486e6441a052ef6cedbb2abcae7c01ce3136fa9f8840b38117ca
import itertools from sympy.core import S from sympy.core.containers import Tuple from sympy.core.function import _coeff_isneg from sympy.core.mul import Mul from sympy.core.numbers import Number, Rational from sympy.core.power import Pow from sympy.core.symbol import Symbol from sympy.core.sympify import SympifyError...
2bc9d220fc0270a0e7e6bc90b7f8c871715ffb914b35b8c6fe9f01d6b3e37f99
"""Symbolic primitives + unicode/ASCII abstraction for pretty.py""" import sys import warnings from string import ascii_lowercase, ascii_uppercase unicode_warnings = '' # first, setup unicodedate environment try: import unicodedata def U(name): """unicode character by name or None if not found""" ...
57a42693da6d78fe336a3af3565764475e0547c50003d3090b6eb709aa3b436e
"""Prettyprinter by Jurjen Bos. (I hate spammers: mail me at pietjepuk314 at the reverse of ku.oc.oohay). All objects have a method that create a "stringPict", that can be used in the str method for pretty printing. Updates by Jason Gedge (email <my last name> at cs mun ca) - terminal_string() method - minor f...
fe74dee1de4115ac89acda2ad15d629793834203b13d67525c289c96bd41a071
from sympy.codegen import Assignment from sympy.codegen.ast import none from sympy.codegen.cfunctions import expm1, log1p from sympy.codegen.scipy_nodes import cosm1 from sympy.codegen.matrix_nodes import MatrixSolve from sympy.core import Expr, Mod, symbols, Eq, Le, Gt, zoo, oo, Rational, Pow from sympy.core.numbers i...
729633562eb434d80ab728933af6c80a96631188825e4d7132eafe998037c055
from sympy import symbols from sympy.functions import beta, Ei, zeta, Max, Min, sqrt from sympy.printing.cxx import CXX98CodePrinter, CXX11CodePrinter, CXX17CodePrinter, cxxcode from sympy.codegen.cfunctions import log1p from sympy.testing.pytest import warns_deprecated_sympy x, y = symbols('x y') def test_CXX98Cod...
38580be1077e73d353f9c4ec7d8926a8c215620fc839855b24b8e8fbbfc3d2ed
from sympy import (Add, Abs, Catalan, cos, Derivative, E, EulerGamma, exp, factorial, factorial2, Function, GoldenRatio, TribonacciConstant, I, Integer, Integral, Interval, Lambda, Limit, Matrix, nan, O, oo, pi, Pow, Rational, Float, Rel, S, sin, SparseMatrix, sqrt, summation, Sum, Symbol, symbols, Wild...
7f9998e634a4350688146d727bb162578bf5506879681f338eacc2bd83caa103
from sympy import (sin, cos, atan2, log, exp, gamma, conjugate, sqrt, factorial, Integral, Piecewise, Add, diff, symbols, S, Float, Dummy, Eq, Range, Catalan, EulerGamma, E, GoldenRatio, I, pi, Function, Rational, Integer, Lambda, sign, Mod) f...
54ea94bc5df22c8f7ecf8744a5bce3dfb1d32639ddadf13207963eee442d8091
from sympy.core import ( S, pi, oo, symbols, Rational, Integer, Float, Mod, GoldenRatio, EulerGamma, Catalan, Lambda, Dummy, Eq, nan, Mul, Pow ) from sympy.functions import ( Abs, acos, acosh, asin, asinh, atan, atanh, atan2, ceiling, cos, cosh, erf, erfc, exp, floor, gamma, log, loggamma, Max, Min, Pie...
9cc1f8ab1c4b378de535bb3d837d78b917f9b021c83f92be770889dd8b52dfb4
from sympy.tensor.toperators import PartialDerivative from sympy import ( Abs, Chi, Ci, CosineTransform, Dict, Ei, Eq, FallingFactorial, FiniteSet, Float, FourierTransform, Function, Indexed, IndexedBase, Integral, Interval, InverseCosineTransform, InverseFourierTransform, Derivative, InverseLaplaceTra...
9cbe588777d6a5b5bfaa52a81d2f83147d92c7bde01417c6802b37c08f2a0da7
from sympy import (Symbol, symbols, oo, limit, Rational, Integral, Derivative, log, exp, sqrt, pi, Function, sin, Eq, Ge, Le, Gt, Lt, Ne, Abs, conjugate, I, Matrix) from sympy.printing.python import python from sympy.testing.pytest import raises, XFAIL x, y = symbols('x,y') th = Symbol('theta') ph = Symbol('...
459eb720b166797b9a862e11e351a5f75ed8cf1be8a16db4ee585b6c5dd1053d
from sympy import TableForm, S from sympy.printing.latex import latex from sympy.abc import x from sympy.functions.elementary.miscellaneous import sqrt from sympy.functions.elementary.trigonometric import sin from sympy.testing.pytest import raises from textwrap import dedent def test_TableForm(): s = str(TableF...
cc5bf052cac41a9bd936630a0f42a2f74e80b176def8538a5d3d19cee41cc027
from sympy import diff, Integral, Limit, sin, Symbol, Integer, Rational, cos, \ tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, E, I, oo, \ pi, GoldenRatio, EulerGamma, Sum, Eq, Ne, Ge, Lt, Float, Matrix, Basic, \ S, MatrixSymbol, Function, Derivative, log, true, false, Range, Min, Max, \ ...
da234d13da7b1ed2bd2aee1b4eb8c0dea14c4afdfe9746e4d90a747f6792f4ae
from sympy.core import (S, pi, oo, symbols, Function, Rational, Integer, Tuple, Symbol, EulerGamma, GoldenRatio, Catalan, Lambda, Mul, Pow, Mod, Eq, Ne, Le, Lt, Gt, Ge) from sympy.codegen.matrix_nodes import MatrixSolve from sympy.functions import (arg, atan2, bernoulli, ...
768d7bf0984936aeae3eea815bf09daa44dde772f33e4e2d3f99168bb2e47e2d
from sympy.external import import_module from sympy.testing.pytest import raises import ctypes if import_module('llvmlite'): import sympy.printing.llvmjitcode as g else: disabled = True import sympy from sympy.abc import a, b, n # copied from numpy.isclose documentation def isclose(a, b): rtol = 1e-5 ...
ccfc6da5b234c4b82583cf216c540c03901ca54625e4eb3366dbefaee5630026
# -*- coding: utf-8 -*- from sympy import ( Add, And, Basic, Derivative, Dict, Eq, Equivalent, FF, FiniteSet, Function, Ge, Gt, I, Implies, Integral, SingularityFunction, Lambda, Le, Limit, Lt, Matrix, Mul, Nand, Ne, Nor, Not, O, Or, Pow, Product, QQ, RR, Rational, Ray, rootof, RootSum, S, Segment, ...
0fb3cede01b51b53ae96bb60500ed27ba3b52b2bfc5dcf8401d96614e2364327
"""Test whether all elements of cls.args are instances of Basic. """ # NOTE: keep tests sorted by (module, class name) key. If a class can't # be instantiated, add it here anyway with @SKIP("abstract class) (see # e.g. Function). import os import re from sympy import (Basic, S, symbols, sqrt, sin, oo, Interval, exp,...
5821ec20767b718d16afe95ef0bc1c08041dd20bccfcb5e660cf131a53ed0fdd
from sympy.core import ( Basic, Rational, Symbol, S, Float, Integer, Mul, Number, Pow, Expr, I, nan, pi, symbols, oo, zoo, N) from sympy.core.tests.test_evalf import NS from sympy.core.function import expand_multinomial from sympy.functions.elementary.miscellaneous import sqrt, cbrt from sympy.functions.element...
3dba29cbd94e0eb77f3f8ebfc71956c4bc2a3df1baff8277096582e08a9f0cbe
from sympy.interactive.session import int_to_Integer def test_int_to_Integer(): assert int_to_Integer("1 + 2.2 + 0x3 + 40") == \ 'Integer (1 )+2.2 +Integer (0x3 )+Integer (40 )' assert int_to_Integer("0b101") == 'Integer (0b101 )' assert int_to_Integer("ab1 + 1 + '1 + 2'") == "ab1 +Integer (1 )+'1...
4dff516c71c4bbb063af757124aa5cad85379990bc6c3d79c4a481873325a6c1
"""Benchmarks for polynomials over Galois fields. """ from sympy.polys.galoistools import gf_from_dict, gf_factor_sqf from sympy.polys.domains import ZZ from sympy import pi, nextprime def gathen_poly(n, p, K): return gf_from_dict({n: K.one, 1: K.one, 0: K.one}, p, K) def shoup_poly(n, p, K): f = [K.one] ...
c1105e4b71f887727ba8c438214b78f0f0ba0edacabb3d4a08ab5a85fe4a0d03
from sympy.polys.rings import ring from sympy.polys.fields import field from sympy.polys.domains import ZZ, QQ from sympy.polys.solvers import solve_lin_sys # Expected times on 3.4 GHz i7: # In [1]: %timeit time_solve_lin_sys_189x49() # 1 loops, best of 3: 864 ms per loop # In [2]: %timeit time_solve_lin_sys_165x165(...
62a1830b37b046ccc2c9efc69e77835cc44d077f0e452a55bbf267d042c8c92a
"""Benchmark of the Groebner bases algorithms. """ from sympy.polys.rings import ring from sympy.polys.domains import QQ from sympy.polys.groebnertools import groebner R, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12 = ring("x1:13", QQ) V = R.gens E = [(x1, x2), (x2, x3), (x1, x4), (x1, x6), (x1, x12), (x2, x5)...
2f978be1152cdde6e14ccb58c56f32e771dd6ed69f9763b01a7bffbec6df0c9d
"""Implementation of :class:`CompositeDomain` class. """ from sympy.polys.domains.domain import Domain from sympy.polys.polyerrors import GeneratorsError from sympy.utilities import public @public class CompositeDomain(Domain): """Base class for composite domains, e.g. ZZ[x], ZZ(X). """ is_Composite = True...
bc76115173eb7c9cc317cc2b77529216a1bc5b3c1f2133ff7b0780f921cf5580
"""Implementation of :class:`CharacteristicZero` class. """ from sympy.polys.domains.domain import Domain from sympy.utilities import public @public class CharacteristicZero(Domain): """Domain that has infinite number of elements. """ has_CharacteristicZero = True def characteristic(self): """R...
cc5ad5a0a68ed382941187d8a01bd64a9dac6aaef7ef4a0cd48423d6b6630152
"""Implementation of :class:`RationalField` class. """ from sympy.polys.domains.characteristiczero import CharacteristicZero from sympy.polys.domains.field import Field from sympy.polys.domains.simpledomain import SimpleDomain from sympy.utilities import public @public class RationalField(Field, CharacteristicZero, ...