modelparameters.sympy.functions.elementary package

Submodules

modelparameters.sympy.functions.elementary.complexes module

class modelparameters.sympy.functions.elementary.complexes.Abs(arg)[source]

Bases: Function

Return the absolute value of the argument.

This is an extension of the built-in function abs() to accept symbolic values. If you pass a SymPy expression to the built-in abs(), it will pass it automatically to Abs().

Examples

>>> from ... import Abs, Symbol, S
>>> Abs(-1)
1
>>> x = Symbol('x', real=True)
>>> Abs(-x)
Abs(x)
>>> Abs(x**2)
x**2
>>> abs(-x) # The Python built-in
Abs(x)

Note that the Python built-in will return either an Expr or int depending on the argument:

>>> type(abs(-1))
<... 'int'>
>>> type(abs(S.NegativeOne))
<class 'sympy.core.numbers.One'>

Abs will always return a sympy object.

See also

sign, conjugate

default_assumptions = {'commutative': True, 'complex': True, 'hermitian': True, 'imaginary': False, 'negative': False, 'nonnegative': True, 'real': True}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Get the first derivative of the argument to Abs().

Examples

>>> from ...abc import x
>>> from ...functions import Abs
>>> Abs(-x).fdiff()
sign(x)
is_commutative = True
is_complex = True
is_hermitian = True
is_imaginary = False
is_negative = False
is_nonnegative = True
is_real = True
unbranched = True
class modelparameters.sympy.functions.elementary.complexes.adjoint(arg)[source]

Bases: Function

Conjugate transpose or Hermite conjugation.

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

class modelparameters.sympy.functions.elementary.complexes.arg(arg)[source]

Bases: Function

Returns the argument (in radians) of a complex number. For a real number, the argument is always 0.

Examples

>>> from ...functions import arg
>>> from ... import I, sqrt
>>> arg(2.0)
0
>>> arg(I)
pi/2
>>> arg(sqrt(2) + I*sqrt(2))
pi/4
default_assumptions = {'commutative': True, 'complex': True, 'finite': True, 'hermitian': True, 'imaginary': False, 'infinite': False, 'real': True}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_commutative = True
is_complex = True
is_finite = True
is_hermitian = True
is_imaginary = False
is_infinite = False
is_real = True
class modelparameters.sympy.functions.elementary.complexes.conjugate(arg)[source]

Bases: Function

Returns the complex conjugate Ref[1] of an argument. In mathematics, the complex conjugate of a complex number is given by changing the sign of the imaginary part.

Thus, the conjugate of the complex number \(a + ib\) (where a and b are real numbers) is \(a - ib\)

Examples

>>> from ... import conjugate, I
>>> conjugate(2)
2
>>> conjugate(I)
-I

See also

sign, Abs

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

class modelparameters.sympy.functions.elementary.complexes.im(arg)[source]

Bases: Function

Returns imaginary part of expression. This function performs only elementary analysis and so it will fail to decompose properly more complicated expressions. If completely simplified result is needed then use Basic.as_real_imag() or perform complex expansion on instance of this function.

Examples

>>> from ... import re, im, E, I
>>> from ...abc import x, y
>>> im(2*E)
0
>>> re(2*I + 17)
17
>>> im(x*I)
re(x)
>>> im(re(x) + y)
im(y)

See also

re

as_real_imag(deep=True, **hints)[source]

Return the imaginary part with a zero real part.

Examples

>>> from ...functions import im
>>> from ... import I
>>> im(2 + 3*I).as_real_imag()
(3, 0)
default_assumptions = {'commutative': True, 'complex': True, 'hermitian': True, 'imaginary': False, 'real': True}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_commutative = True
is_complex = True
is_hermitian = True
is_imaginary = False
is_real = True
unbranched = True
class modelparameters.sympy.functions.elementary.complexes.periodic_argument(ar, period)[source]

Bases: Function

Represent the argument on a quotient of the Riemann surface of the logarithm. That is, given a period P, always return a value in (-P/2, P/2], by using exp(P*I) == 1.

>>> from ... import exp, exp_polar, periodic_argument, unbranched_argument
>>> from ... import I, pi
>>> unbranched_argument(exp(5*I*pi))
pi
>>> unbranched_argument(exp_polar(5*I*pi))
5*pi
>>> periodic_argument(exp_polar(5*I*pi), 2*pi)
pi
>>> periodic_argument(exp_polar(5*I*pi), 3*pi)
-pi
>>> periodic_argument(exp_polar(5*I*pi), pi)
0

See also

sympy.functions.elementary.exponential.exp_polar

polar_lift

Lift argument to the Riemann surface of the logarithm

principal_branch

default_assumptions = {}
classmethod eval(ar, period)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

class modelparameters.sympy.functions.elementary.complexes.polar_lift(arg)[source]

Bases: Function

Lift argument to the Riemann surface of the logarithm, using the standard branch.

>>> from ... import Symbol, polar_lift, I
>>> p = Symbol('p', polar=True)
>>> x = Symbol('x')
>>> polar_lift(4)
4*exp_polar(0)
>>> polar_lift(-4)
4*exp_polar(I*pi)
>>> polar_lift(-I)
exp_polar(-I*pi/2)
>>> polar_lift(I + 2)
polar_lift(2 + I)
>>> polar_lift(4*x)
4*polar_lift(x)
>>> polar_lift(4*p)
4*p

See also

sympy.functions.elementary.exponential.exp_polar, periodic_argument

default_assumptions = {'polar': True}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_comparable = False
is_polar = True
modelparameters.sympy.functions.elementary.complexes.polarify(eq, subs=True, lift=False)[source]

Turn all numbers in eq into their polar equivalents (under the standard choice of argument).

Note that no attempt is made to guess a formal convention of adding polar numbers, expressions like 1 + x will generally not be altered.

Note also that this function does not promote exp(x) to exp_polar(x).

If subs is True, all symbols which are not already polar will be substituted for polar dummies; in this case the function behaves much like posify.

If lift is True, both addition statements and non-polar symbols are changed to their polar_lift()ed versions. Note that lift=True implies subs=False.

>>> from ... import polarify, sin, I
>>> from ...abc import x, y
>>> expr = (-x)**y
>>> expr.expand()
(-x)**y
>>> polarify(expr)
((_x*exp_polar(I*pi))**_y, {_x: x, _y: y})
>>> polarify(expr)[0].expand()
_x**_y*exp_polar(_y*I*pi)
>>> polarify(x, lift=True)
polar_lift(x)
>>> polarify(x*(1+y), lift=True)
polar_lift(x)*polar_lift(y + 1)

Adds are treated carefully:

>>> polarify(1 + sin((1 + I)*x))
(sin(_x*polar_lift(1 + I)) + 1, {_x: x})
class modelparameters.sympy.functions.elementary.complexes.principal_branch(x, period)[source]

Bases: Function

Represent a polar number reduced to its principal branch on a quotient of the Riemann surface of the logarithm.

This is a function of two arguments. The first argument is a polar number z, and the second one a positive real number of infinity, p. The result is “z mod exp_polar(I*p)”.

>>> from ... import exp_polar, principal_branch, oo, I, pi
>>> from ...abc import z
>>> principal_branch(z, oo)
z
>>> principal_branch(exp_polar(2*pi*I)*3, 2*pi)
3*exp_polar(0)
>>> principal_branch(exp_polar(2*pi*I)*3*z, 2*pi)
3*principal_branch(z, 2*pi)

See also

sympy.functions.elementary.exponential.exp_polar

polar_lift

Lift argument to the Riemann surface of the logarithm

periodic_argument

default_assumptions = {'polar': True}
classmethod eval(x, period)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_comparable = False
is_polar = True
class modelparameters.sympy.functions.elementary.complexes.re(arg)[source]

Bases: Function

Returns real part of expression. This function performs only elementary analysis and so it will fail to decompose properly more complicated expressions. If completely simplified result is needed then use Basic.as_real_imag() or perform complex expansion on instance of this function.

Examples

>>> from ... import re, im, I, E
>>> from ...abc import x, y
>>> re(2*E)
2*E
>>> re(2*I + 17)
17
>>> re(2*I)
0
>>> re(im(x) + x*I + 2)
2

See also

im

as_real_imag(deep=True, **hints)[source]

Returns the real number with a zero imaginary part.

default_assumptions = {'commutative': True, 'complex': True, 'hermitian': True, 'imaginary': False, 'real': True}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_commutative = True
is_complex = True
is_hermitian = True
is_imaginary = False
is_real = True
unbranched = True
class modelparameters.sympy.functions.elementary.complexes.sign(arg)[source]

Bases: Function

Returns the complex sign of an expression:

If the expresssion is real the sign will be:

  • 1 if expression is positive

  • 0 if expression is equal to zero

  • -1 if expression is negative

If the expresssion is imaginary the sign will be:

  • I if im(expression) is positive

  • -I if im(expression) is negative

Otherwise an unevaluated expression will be returned. When evaluated, the result (in general) will be cos(arg(expr)) + I*sin(arg(expr)).

Examples

>>> from ...functions import sign
>>> from ...core.numbers import I
>>> sign(-1)
-1
>>> sign(0)
0
>>> sign(-3*I)
-I
>>> sign(1 + I)
sign(1 + I)
>>> _.evalf()
0.707106781186548 + 0.707106781186548*I

See also

Abs, conjugate

default_assumptions = {'commutative': True, 'complex': True, 'finite': True, 'infinite': False}
doit(**hints)[source]

Evaluate objects that are not evaluated by default like limits, integrals, sums and products. All objects of this kind will be evaluated recursively, unless some species were excluded via ‘hints’ or unless the ‘deep’ hint was set to ‘False’.

>>> from .. import Integral
>>> from ..abc import x
>>> 2*Integral(x, x)
2*Integral(x, x)
>>> (2*Integral(x, x)).doit()
x**2
>>> (2*Integral(x, x)).doit(deep=False)
2*Integral(x, x)
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_commutative = True
is_complex = True
is_finite = True
is_infinite = False
class modelparameters.sympy.functions.elementary.complexes.transpose(arg)[source]

Bases: Function

Linear map transposition.

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

modelparameters.sympy.functions.elementary.complexes.unbranched_argument(arg)[source]
modelparameters.sympy.functions.elementary.complexes.unpolarify(eq, subs={}, exponents_only=False)[source]

If p denotes the projection from the Riemann surface of the logarithm to the complex line, return a simplified version eq’ of eq such that p(eq’) == p(eq). Also apply the substitution subs in the end. (This is a convenience, since unpolarify, in a certain sense, undoes polarify.)

>>> from ... import unpolarify, polar_lift, sin, I
>>> unpolarify(polar_lift(I + 2))
2 + I
>>> unpolarify(sin(polar_lift(I + 7)))
sin(7 + I)

modelparameters.sympy.functions.elementary.exponential module

class modelparameters.sympy.functions.elementary.exponential.ExpBase(*args)[source]

Bases: Function

as_base_exp()[source]

Returns the 2-tuple (base, exponent).

as_numer_denom()[source]

Returns this with a positive exponent as a 2-tuple (a fraction).

Examples

>>> from ...functions import exp
>>> from ...abc import x
>>> exp(-x).as_numer_denom()
(1, exp(x))
>>> exp(x).as_numer_denom()
(exp(x), 1)
default_assumptions = {}
property exp

Returns the exponent of the function.

inverse(argindex=1)[source]

Returns the inverse function of exp(x).

unbranched = True
class modelparameters.sympy.functions.elementary.exponential.LambertW(x, k=None)[source]

Bases: Function

The Lambert W function W(z) is defined as the inverse function of w exp(w) [1]_.

In other words, the value of W(z) is such that z = W(z) exp(W(z)) for any complex number z. The Lambert W function is a multivalued function with infinitely many branches W_k(z), indexed by k in mathbb{Z}. Each branch gives a different solution w of the equation z = w exp(w).

The Lambert W function has two partially real branches: the principal branch (k = 0) is real for real z > -1/e, and the k = -1 branch is real for -1/e < z < 0. All branches except k = 0 have a logarithmic singularity at z = 0.

Examples

>>> from ... import LambertW
>>> LambertW(1.2)
0.635564016364870
>>> LambertW(1.2, -1).n()
-1.34747534407696 - 4.41624341514535*I
>>> LambertW(-1).is_real
False

References

default_assumptions = {}
classmethod eval(x, k=None)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Return the first derivative of this function.

class modelparameters.sympy.functions.elementary.exponential.exp(arg)[source]

Bases: ExpBase

The exponential function, \(e^x\).

See also

log

as_real_imag(deep=True, **hints)[source]

Returns this function as a 2-tuple representing a complex number.

Examples

>>> from ... import I
>>> from ...abc import x
>>> from ...functions import exp
>>> exp(x).as_real_imag()
(exp(re(x))*cos(im(x)), exp(re(x))*sin(im(x)))
>>> exp(1).as_real_imag()
(E, 0)
>>> exp(I).as_real_imag()
(cos(1), sin(1))
>>> exp(1+I).as_real_imag()
(E*cos(1), E*sin(1))

See also

sympy.functions.elementary.complexes.re, sympy.functions.elementary.complexes.im

property base

Returns the base of the exponential function.

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of this function.

static taylor_term(n, x, *previous_terms)[source]

Calculates the next term in the Taylor series expansion.

class modelparameters.sympy.functions.elementary.exponential.exp_polar(*args)[source]

Bases: ExpBase

Represent a ‘polar number’ (see g-function Sphinx documentation).

exp_polar represents the function Exp: mathbb{C} rightarrow mathcal{S}, sending the complex number z = a + bi to the polar number r = exp(a), theta = b. It is one of the main functions to construct polar numbers.

>>> from ... import exp_polar, pi, I, exp

The main difference is that polar numbers don’t “wrap around” at 2 pi:

>>> exp(2*pi*I)
1
>>> exp_polar(2*pi*I)
exp_polar(2*I*pi)

apart from that they behave mostly like classical complex numbers:

>>> exp_polar(2)*exp_polar(3)
exp_polar(5)

See also

sympy.simplify.simplify.powsimp, sympy.functions.elementary.complexes.polar_lift, sympy.functions.elementary.complexes.periodic_argument, sympy.functions.elementary.complexes.principal_branch

as_base_exp()[source]

Returns the 2-tuple (base, exponent).

default_assumptions = {'polar': True}
is_comparable = False
is_polar = True
class modelparameters.sympy.functions.elementary.exponential.log(arg, base=None)[source]

Bases: Function

The natural logarithm function ln(x) or log(x). Logarithms are taken with the natural base, e. To get a logarithm of a different base b, use log(x, b), which is essentially short-hand for log(x)/log(b).

See also

exp

as_base_exp()[source]

Returns this function in the form (base, exponent).

as_real_imag(deep=True, **hints)[source]

Returns this function as a complex coordinate.

Examples

>>> from ... import I
>>> from ...abc import x
>>> from ...functions import log
>>> log(x).as_real_imag()
(log(Abs(x)), arg(x))
>>> log(I).as_real_imag()
(0, pi/2)
>>> log(1 + I).as_real_imag()
(log(sqrt(2)), pi/4)
>>> log(I*x).as_real_imag()
(log(Abs(x)), arg(I*x))
default_assumptions = {}
classmethod eval(arg, base=None)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns e^x, the inverse function of log(x).

static taylor_term(n, x, *previous_terms)[source]

Returns the next term in the Taylor series expansion of log(1+x).

modelparameters.sympy.functions.elementary.hyperbolic module

class modelparameters.sympy.functions.elementary.hyperbolic.HyperbolicFunction(*args)[source]

Bases: Function

Base class for hyperbolic functions.

See also

sinh, cosh, tanh, coth

default_assumptions = {}
unbranched = True
class modelparameters.sympy.functions.elementary.hyperbolic.ReciprocalHyperbolicFunction(arg)[source]

Bases: HyperbolicFunction

Base class for reciprocal functions of hyperbolic functions.

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

class modelparameters.sympy.functions.elementary.hyperbolic.acosh(arg)[source]

Bases: Function

The inverse hyperbolic cosine function.

  • acosh(x) -> Returns the inverse hyperbolic cosine of x

See also

asinh, atanh, cosh

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.acoth(arg)[source]

Bases: Function

The inverse hyperbolic cotangent function.

  • acoth(x) -> Returns the inverse hyperbolic cotangent of x

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.acsch(arg)[source]

Bases: Function

The inverse hyperbolic cosecant function.

  • acsch(x) -> Returns the inverse hyperbolic cosecant of x

Examples

>>> from ... import acsch, sqrt, S
>>> from ...abc import x
>>> acsch(x).diff(x)
-1/(x**2*sqrt(1 + x**(-2)))
>>> acsch(1).diff(x)
0
>>> acsch(1)
log(1 + sqrt(2))
>>> acsch(S.ImaginaryUnit)
-I*pi/2
>>> acsch(-2*S.ImaginaryUnit)
I*pi/6
>>> acsch(S.ImaginaryUnit*(sqrt(6) - sqrt(2)))
-5*I*pi/12

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

class modelparameters.sympy.functions.elementary.hyperbolic.asech(arg)[source]

Bases: Function

The inverse hyperbolic secant function.

  • asech(x) -> Returns the inverse hyperbolic secant of x

Examples

>>> from ... import asech, sqrt, S
>>> from ...abc import x
>>> asech(x).diff(x)
-1/(x*sqrt(-x**2 + 1))
>>> asech(1).diff(x)
0
>>> asech(1)
0
>>> asech(S(2))
I*pi/3
>>> asech(-sqrt(2))
3*I*pi/4
>>> asech((sqrt(6) - sqrt(2)))
I*pi/12

See also

asinh, atanh, cosh, acoth

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

static expansion_term(n, x, *previous_terms)[source]
fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

class modelparameters.sympy.functions.elementary.hyperbolic.asinh(arg)[source]

Bases: Function

The inverse hyperbolic sine function.

  • asinh(x) -> Returns the inverse hyperbolic sine of x

See also

acosh, atanh, sinh

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.atanh(arg)[source]

Bases: Function

The inverse hyperbolic tangent function.

  • atanh(x) -> Returns the inverse hyperbolic tangent of x

See also

asinh, acosh, tanh

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.cosh(arg)[source]

Bases: HyperbolicFunction

The hyperbolic cosine function, frac{e^x + e^{-x}}{2}.

  • cosh(x) -> Returns the hyperbolic cosine of x

See also

sinh, tanh, acosh

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.coth(arg)[source]

Bases: HyperbolicFunction

The hyperbolic cotangent function, frac{cosh(x)}{sinh(x)}.

  • coth(x) -> Returns the hyperbolic cotangent of x

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.csch(arg)[source]

Bases: ReciprocalHyperbolicFunction

The hyperbolic cosecant function, frac{2}{e^x - e^{-x}}

  • csch(x) -> Returns the hyperbolic cosecant of x

See also

sinh, cosh, tanh, sech, asinh, acosh

default_assumptions = {}
fdiff(argindex=1)[source]

Returns the first derivative of this function

static taylor_term(n, x, *previous_terms)[source]

Returns the next term in the Taylor series expansion

class modelparameters.sympy.functions.elementary.hyperbolic.sech(arg)[source]

Bases: ReciprocalHyperbolicFunction

The hyperbolic secant function, frac{2}{e^x + e^{-x}}

  • sech(x) -> Returns the hyperbolic secant of x

See also

sinh, cosh, tanh, coth, csch, asinh, acosh

default_assumptions = {}
fdiff(argindex=1)[source]

Returns the first derivative of the function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.hyperbolic.sinh(arg)[source]

Bases: HyperbolicFunction

The hyperbolic sine function, frac{e^x - e^{-x}}{2}.

  • sinh(x) -> Returns the hyperbolic sine of x

See also

cosh, tanh, asinh

as_real_imag(deep=True, **hints)[source]

Returns this function as a complex coordinate.

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of this function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

Returns the next term in the Taylor series expansion.

class modelparameters.sympy.functions.elementary.hyperbolic.tanh(arg)[source]

Bases: HyperbolicFunction

The hyperbolic tangent function, frac{sinh(x)}{cosh(x)}.

  • tanh(x) -> Returns the hyperbolic tangent of x

See also

sinh, cosh, atanh

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

modelparameters.sympy.functions.elementary.integers module

class modelparameters.sympy.functions.elementary.integers.RoundFunction(arg)[source]

Bases: Function

The base class for rounding functions.

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

class modelparameters.sympy.functions.elementary.integers.ceiling(arg)[source]

Bases: RoundFunction

Ceiling is a univariate function which returns the smallest integer value not less than its argument. Ceiling function is generalized in this implementation to complex numbers.

Examples

>>> from ... import ceiling, E, I, Float, Rational
>>> ceiling(17)
17
>>> ceiling(Rational(23, 10))
3
>>> ceiling(2*E)
6
>>> ceiling(-Float(0.567))
0
>>> ceiling(I/2)
I

See also

sympy.functions.elementary.integers.floor

References

default_assumptions = {}
class modelparameters.sympy.functions.elementary.integers.floor(arg)[source]

Bases: RoundFunction

Floor is a univariate function which returns the largest integer value not greater than its argument. However this implementation generalizes floor to complex numbers.

Examples

>>> from ... import floor, E, I, Float, Rational
>>> floor(17)
17
>>> floor(Rational(23, 10))
2
>>> floor(2*E)
5
>>> floor(-Float(0.567))
-1
>>> floor(-I/2)
-I

See also

sympy.functions.elementary.integers.ceiling

References

default_assumptions = {}
class modelparameters.sympy.functions.elementary.integers.frac(arg)[source]

Bases: Function

Represents the fractional part of x

For real numbers it is defined [1]_ as

\[x - \lfloor{x}\rfloor\]

Examples

>>> from ... import Symbol, frac, Rational, floor, ceiling, I
>>> frac(Rational(4, 3))
1/3
>>> frac(-Rational(4, 3))
2/3

returns zero for integer arguments

>>> n = Symbol('n', integer=True)
>>> frac(n)
0

rewrite as floor

>>> x = Symbol('x')
>>> frac(x).rewrite(floor)
x - floor(x)

for complex arguments

>>> r = Symbol('r', real=True)
>>> t = Symbol('t', real=True)
>>> frac(t + I*r)
I*frac(r) + frac(t)

See also

sympy.functions.elementary.integers.floor, sympy.functions.elementary.integers.ceiling

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

modelparameters.sympy.functions.elementary.miscellaneous module

class modelparameters.sympy.functions.elementary.miscellaneous.IdentityFunction(*args, **kwargs)[source]

Bases: Lambda

The identity function

Examples

>>> from ... import Id, Symbol
>>> x = Symbol('x')
>>> Id(x)
x
default_assumptions = {}
class modelparameters.sympy.functions.elementary.miscellaneous.Max(*args)[source]

Bases: MinMaxBase, Application

Return, if possible, the maximum value of the list.

When number of arguments is equal one, then return this argument.

When number of arguments is equal two, then return, if possible, the value from (a, b) that is >= the other.

In common case, when the length of list greater than 2, the task is more complicated. Return only the arguments, which are greater than others, if it is possible to determine directional relation.

If is not possible to determine such a relation, return a partially evaluated result.

Assumptions are used to make the decision too.

Also, only comparable arguments are permitted.

It is named Max and not max to avoid conflicts with the built-in function max.

Examples

>>> from ... import Max, Symbol, oo
>>> from ...abc import x, y
>>> p = Symbol('p', positive=True)
>>> n = Symbol('n', negative=True)
>>> Max(x, -2)                  
Max(x, -2)
>>> Max(x, -2).subs(x, 3)
3
>>> Max(p, -2)
p
>>> Max(x, y)
Max(x, y)
>>> Max(x, y) == Max(y, x)
True
>>> Max(x, Max(y, z))           
Max(x, y, z)
>>> Max(n, 8, p, 7, -oo)        
Max(8, p)
>>> Max (1, x, oo)
oo
  • Algorithm

The task can be considered as searching of supremums in the directed complete partial orders [1]_.

The source values are sequentially allocated by the isolated subsets in which supremums are searched and result as Max arguments.

If the resulted supremum is single, then it is returned.

The isolated subsets are the sets of values which are only the comparable with each other in the current set. E.g. natural numbers are comparable with each other, but not comparable with the x symbol. Another example: the symbol x with negative assumption is comparable with a natural number.

Also there are “least” elements, which are comparable with all others, and have a zero property (maximum or minimum for all elements). E.g. oo. In case of it the allocation operation is terminated and only this value is returned.

Assumption:
  • if A > B > C then A > C

  • if A == B then B can be removed

References

See also

Min

find minimum values

default_assumptions = {'commutative': True}
fdiff(argindex)[source]
identity = -oo
is_commutative = True
zero = oo
class modelparameters.sympy.functions.elementary.miscellaneous.Min(*args)[source]

Bases: MinMaxBase, Application

Return, if possible, the minimum value of the list. It is named Min and not min to avoid conflicts with the built-in function min.

Examples

>>> from ... import Min, Symbol, oo
>>> from ...abc import x, y
>>> p = Symbol('p', positive=True)
>>> n = Symbol('n', negative=True)
>>> Min(x, -2)                  
Min(x, -2)
>>> Min(x, -2).subs(x, 3)
-2
>>> Min(p, -3)
-3
>>> Min(x, y)                   
Min(x, y)
>>> Min(n, 8, p, -7, p, oo)     
Min(n, -7)

See also

Max

find maximum values

default_assumptions = {'commutative': True}
fdiff(argindex)[source]
identity = oo
is_commutative = True
zero = -oo
class modelparameters.sympy.functions.elementary.miscellaneous.MinMaxBase(*args, **assumptions)[source]

Bases: Expr, LatticeOp

default_assumptions = {'commutative': True}
evalf(prec=None, **options)[source]

Evaluate the given formula to an accuracy of n digits. Optional keyword arguments:

subs=<dict>

Substitute numerical values for symbols, e.g. subs={x:3, y:1+pi}. The substitutions must be given as a dictionary.

maxn=<integer>

Allow a maximum temporary working precision of maxn digits (default=100)

chop=<bool>

Replace tiny real or imaginary parts in subresults by exact zeros (default=False)

strict=<bool>

Raise PrecisionExhausted if any subresult fails to evaluate to full accuracy, given the available maxprec (default=False)

quad=<str>

Choose algorithm for numerical quadrature. By default, tanh-sinh quadrature is used. For oscillatory integrals on an infinite interval, try quad=’osc’.

verbose=<bool>

Print debug information (default=False)

is_commutative = True
n(prec=None, **options)

Evaluate the given formula to an accuracy of n digits. Optional keyword arguments:

subs=<dict>

Substitute numerical values for symbols, e.g. subs={x:3, y:1+pi}. The substitutions must be given as a dictionary.

maxn=<integer>

Allow a maximum temporary working precision of maxn digits (default=100)

chop=<bool>

Replace tiny real or imaginary parts in subresults by exact zeros (default=False)

strict=<bool>

Raise PrecisionExhausted if any subresult fails to evaluate to full accuracy, given the available maxprec (default=False)

quad=<str>

Choose algorithm for numerical quadrature. By default, tanh-sinh quadrature is used. For oscillatory integrals on an infinite interval, try quad=’osc’.

verbose=<bool>

Print debug information (default=False)

modelparameters.sympy.functions.elementary.miscellaneous.cbrt(arg)[source]

This function computes the principial cube root of arg, so it’s just a shortcut for arg**Rational(1, 3).

Examples

>>> from ... import cbrt, Symbol
>>> x = Symbol('x')
>>> cbrt(x)
x**(1/3)
>>> cbrt(x)**3
x

Note that cbrt(x**3) does not simplify to x.

>>> cbrt(x**3)
(x**3)**(1/3)

This is because the two are not equal to each other in general. For example, consider x == -1:

>>> from ... import Eq
>>> Eq(cbrt(x**3), x).subs(x, -1)
False

This is because cbrt computes the principal cube root, this identity does hold if x is positive:

>>> y = Symbol('y', positive=True)
>>> cbrt(y**3)
y

See also

sympy.polys.rootoftools.rootof, root, real_root

References

modelparameters.sympy.functions.elementary.miscellaneous.real_root(arg, n=None)[source]

Return the real nth-root of arg if possible. If n is omitted then all instances of (-n)**(1/odd) will be changed to -n**(1/odd); this will only create a real root of a principle root – the presence of other factors may cause the result to not be real.

Examples

>>> from ... import root, real_root, Rational
>>> from ...abc import x, n
>>> real_root(-8, 3)
-2
>>> root(-8, 3)
2*(-1)**(1/3)
>>> real_root(_)
-2

If one creates a non-principle root and applies real_root, the result will not be real (so use with caution):

>>> root(-8, 3, 2)
-2*(-1)**(2/3)
>>> real_root(_)
-2*(-1)**(2/3)

See also

sympy.polys.rootoftools.rootof, sympy.core.power.integer_nthroot, root, sqrt

modelparameters.sympy.functions.elementary.miscellaneous.root(x, n, k) Returns the k-th n-th root of x, defaulting to the[source]

principle root (k=0).

Examples

>>> from ... import root, Rational
>>> from ...abc import x, n
>>> root(x, 2)
sqrt(x)
>>> root(x, 3)
x**(1/3)
>>> root(x, n)
x**(1/n)
>>> root(x, -Rational(2, 3))
x**(-3/2)

To get the k-th n-th root, specify k:

>>> root(-2, 3, 2)
-(-1)**(2/3)*2**(1/3)

To get all n n-th roots you can use the rootof function. The following examples show the roots of unity for n equal 2, 3 and 4:

>>> from ... import rootof, I
>>> [rootof(x**2 - 1, i) for i in range(2)]
[-1, 1]
>>> [rootof(x**3 - 1,i) for i in range(3)]
[1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2]
>>> [rootof(x**4 - 1,i) for i in range(4)]
[-1, 1, -I, I]

SymPy, like other symbolic algebra systems, returns the complex root of negative numbers. This is the principal root and differs from the text-book result that one might be expecting. For example, the cube root of -8 does not come back as -2:

>>> root(-8, 3)
2*(-1)**(1/3)

The real_root function can be used to either make the principle result real (or simply to return the real root directly):

>>> from ... import real_root
>>> real_root(_)
-2
>>> real_root(-32, 5)
-2

Alternatively, the n//2-th n-th root of a negative number can be computed with root:

>>> root(-32, 5, 5//2)
-2

See also

sympy.polys.rootoftools.rootof, sympy.core.power.integer_nthroot, sqrt, real_root

References

modelparameters.sympy.functions.elementary.miscellaneous.sqrt(arg)[source]

The square root function

sqrt(x) -> Returns the principal square root of x.

Examples

>>> from ... import sqrt, Symbol
>>> x = Symbol('x')
>>> sqrt(x)
sqrt(x)
>>> sqrt(x)**2
x

Note that sqrt(x**2) does not simplify to x.

>>> sqrt(x**2)
sqrt(x**2)

This is because the two are not equal to each other in general. For example, consider x == -1:

>>> from ... import Eq
>>> Eq(sqrt(x**2), x).subs(x, -1)
False

This is because sqrt computes the principal square root, so the square may put the argument in a different branch. This identity does hold if x is positive:

>>> y = Symbol('y', positive=True)
>>> sqrt(y**2)
y

You can force this simplification by using the powdenest() function with the force option set to True:

>>> from ... import powdenest
>>> sqrt(x**2)
sqrt(x**2)
>>> powdenest(sqrt(x**2), force=True)
x

To get both branches of the square root you can use the rootof function:

>>> from ... import rootof
>>> [rootof(x**2-3,i) for i in (0,1)]
[-sqrt(3), sqrt(3)]

See also

sympy.polys.rootoftools.rootof, root, real_root

References

modelparameters.sympy.functions.elementary.piecewise module

class modelparameters.sympy.functions.elementary.piecewise.ExprCondPair(expr, cond)[source]

Bases: Tuple

Represents an expression, condition pair.

property cond

Returns the condition of this pair.

default_assumptions = {}
property expr

Returns the expression of this pair.

property free_symbols

Return the free symbols of this pair.

property is_commutative
class modelparameters.sympy.functions.elementary.piecewise.Piecewise(*args)[source]

Bases: Function

Represents a piecewise function.

Usage:

Piecewise( (expr,cond), (expr,cond), … )
  • Each argument is a 2-tuple defining an expression and condition

  • The conds are evaluated in turn returning the first that is True. If any of the evaluated conds are not determined explicitly False, e.g. x < 1, the function is returned in symbolic form.

  • If the function is evaluated at a place where all conditions are False, a ValueError exception will be raised.

  • Pairs where the cond is explicitly False, will be removed.

Examples

>>> from ... import Piecewise, log
>>> from ...abc import x
>>> f = x**2
>>> g = log(x)
>>> p = Piecewise( (0, x<-1), (f, x<=1), (g, True))
>>> p.subs(x,1)
1
>>> p.subs(x,5)
log(5)

See also

piecewise_fold

as_expr_set_pairs()[source]
default_assumptions = {}
doit(**hints)[source]

Evaluate this piecewise function.

classmethod eval(*args)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

is_Piecewise = True
nargs = S.Naturals0
modelparameters.sympy.functions.elementary.piecewise.piecewise_fold(expr)[source]

Takes an expression containing a piecewise function and returns the expression in piecewise form.

Examples

>>> from ... import Piecewise, piecewise_fold, sympify as S
>>> from ...abc import x
>>> p = Piecewise((x, x < 1), (1, S(1) <= x))
>>> piecewise_fold(x*p)
Piecewise((x**2, x < 1), (x, 1 <= x))

See also

Piecewise

modelparameters.sympy.functions.elementary.trigonometric module

class modelparameters.sympy.functions.elementary.trigonometric.InverseTrigonometricFunction(*args)[source]

Bases: Function

Base class for inverse trigonometric functions.

default_assumptions = {}
class modelparameters.sympy.functions.elementary.trigonometric.ReciprocalTrigonometricFunction(arg)[source]

Bases: TrigonometricFunction

Base class for reciprocal functions of trigonometric functions.

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

class modelparameters.sympy.functions.elementary.trigonometric.TrigonometricFunction(*args)[source]

Bases: Function

Base class for trigonometric functions.

default_assumptions = {}
unbranched = True
class modelparameters.sympy.functions.elementary.trigonometric.acos(arg)[source]

Bases: InverseTrigonometricFunction

The inverse cosine function.

Returns the arc cosine of x (measured in radians).

Notes

acos(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1.

acos(zoo) evaluates to zoo (see note in :py:class`sympy.functions.elementary.trigonometric.asec`)

Examples

>>> from ... import acos, oo, pi
>>> acos(1)
0
>>> acos(0)
pi/2
>>> acos(oo)
oo*I

See also

sin, csc, cos, sec, tan, cot, asin, acsc, asec, atan, acot, atan2

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.acot(arg)[source]

Bases: InverseTrigonometricFunction

The inverse cotangent function.

Returns the arc cotangent of x (measured in radians).

See also

sin, csc, cos, sec, tan, cot, asin, acsc, acos, asec, atan, atan2

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.acsc(arg)[source]

Bases: InverseTrigonometricFunction

The inverse cosecant function.

Returns the arc cosecant of x (measured in radians).

Notes

acsc(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1.

Examples

>>> from ... import acsc, oo, pi
>>> acsc(1)
pi/2
>>> acsc(-1)
-pi/2

See also

sin, csc, cos, sec, tan, cot, asin, acos, asec, atan, acot, atan2

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

class modelparameters.sympy.functions.elementary.trigonometric.asec(arg)[source]

Bases: InverseTrigonometricFunction

The inverse secant function.

Returns the arc secant of x (measured in radians).

Notes

asec(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1.

asec(x) has branch cut in the interval [-1, 1]. For complex arguments, it can be defined [4]_ as

\[sec^{-1}(z) = -i*(log(\sqrt{1 - z^2} + 1) / z)\]

At x = 0, for positive branch cut, the limit evaluates to zoo. For negative branch cut, the limit

\[\lim_{z \to 0}-i*(log(-\sqrt{1 - z^2} + 1) / z)\]

simplifies to \(-i*log(z/2 + O(z^3))\) which ultimately evaluates to zoo.

As asex(x) = asec(1/x), a similar argument can be given for acos(x).

Examples

>>> from ... import asec, oo, pi
>>> asec(1)
0
>>> asec(-1)
pi

See also

sin, csc, cos, sec, tan, cot, asin, acsc, acos, atan, acot, atan2

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

class modelparameters.sympy.functions.elementary.trigonometric.asin(arg)[source]

Bases: InverseTrigonometricFunction

The inverse sine function.

Returns the arcsine of x in radians.

Notes

asin(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1 and for some instances when the result is a rational multiple of pi (see the eval class method).

Examples

>>> from ... import asin, oo, pi
>>> asin(1)
pi/2
>>> asin(-1)
-pi/2

See also

sin, csc, cos, sec, tan, cot, acsc, acos, asec, atan, acot, atan2

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.atan(arg)[source]

Bases: InverseTrigonometricFunction

The inverse tangent function.

Returns the arc tangent of x (measured in radians).

Notes

atan(x) will evaluate automatically in the cases oo, -oo, 0, 1, -1.

Examples

>>> from ... import atan, oo, pi
>>> atan(0)
0
>>> atan(1)
pi/4
>>> atan(oo)
pi/2

See also

sin, csc, cos, sec, tan, cot, asin, acsc, acos, asec, acot, atan2

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.atan2(y, x)[source]

Bases: InverseTrigonometricFunction

The function atan2(y, x) computes operatorname{atan}(y/x) taking two arguments y and x. Signs of both y and x are considered to determine the appropriate quadrant of operatorname{atan}(y/x). The range is (-pi, pi]. The complete definition reads as follows:

\[\begin{split}\operatorname{atan2}(y, x) = \begin{cases} \arctan\left(\frac y x\right) & \qquad x > 0 \\ \arctan\left(\frac y x\right) + \pi& \qquad y \ge 0 , x < 0 \\ \arctan\left(\frac y x\right) - \pi& \qquad y < 0 , x < 0 \\ +\frac{\pi}{2} & \qquad y > 0 , x = 0 \\ -\frac{\pi}{2} & \qquad y < 0 , x = 0 \\ \text{undefined} & \qquad y = 0, x = 0 \end{cases}\end{split}\]

Attention: Note the role reversal of both arguments. The y-coordinate is the first argument and the x-coordinate the second.

Examples

Going counter-clock wise around the origin we find the following angles:

>>> from ... import atan2
>>> atan2(0, 1)
0
>>> atan2(1, 1)
pi/4
>>> atan2(1, 0)
pi/2
>>> atan2(1, -1)
3*pi/4
>>> atan2(0, -1)
pi
>>> atan2(-1, -1)
-3*pi/4
>>> atan2(-1, 0)
-pi/2
>>> atan2(-1, 1)
-pi/4

which are all correct. Compare this to the results of the ordinary operatorname{atan} function for the point (x, y) = (-1, 1)

>>> from ... import atan, S
>>> atan(S(1) / -1)
-pi/4
>>> atan2(1, -1)
3*pi/4

where only the operatorname{atan2} function reurns what we expect. We can differentiate the function with respect to both arguments:

>>> from ... import diff
>>> from ...abc import x, y
>>> diff(atan2(y, x), x)
-y/(x**2 + y**2)
>>> diff(atan2(y, x), y)
x/(x**2 + y**2)

We can express the operatorname{atan2} function in terms of complex logarithms:

>>> from ... import log
>>> atan2(y, x).rewrite(log)
-I*log((x + I*y)/sqrt(x**2 + y**2))

and in terms of operatorname(atan):

>>> from ... import atan
>>> atan2(y, x).rewrite(atan)
2*atan(y/(x + sqrt(x**2 + y**2)))

but note that this form is undefined on the negative real axis.

See also

sin, csc, cos, sec, tan, cot, asin, acsc, acos, asec, atan, acot

References

default_assumptions = {}
classmethod eval(y, x)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex)[source]

Returns the first derivative of the function.

class modelparameters.sympy.functions.elementary.trigonometric.cos(arg)[source]

Bases: TrigonometricFunction

The cosine function.

Returns the cosine of x (measured in radians).

Notes

See sin() for notes about automatic evaluation.

Examples

>>> from ... import cos, pi
>>> from ...abc import x
>>> cos(x**2).diff(x)
-2*x*sin(x**2)
>>> cos(1).diff(x)
0
>>> cos(pi)
-1
>>> cos(pi/2)
0
>>> cos(2*pi/3)
-1/2
>>> cos(pi/12)
sqrt(2)/4 + sqrt(6)/4

See also

sin, csc, sec, tan, cot, asin, acsc, acos, asec, atan, acot, atan2

References

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

period(symbol=None)[source]
static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.cot(arg)[source]

Bases: TrigonometricFunction

The cotangent function.

Returns the cotangent of x (measured in radians).

Notes

See sin() for notes about automatic evaluation.

Examples

>>> from ... import cot, pi
>>> from ...abc import x
>>> cot(x**2).diff(x)
2*x*(-cot(x**2)**2 - 1)
>>> cot(1).diff(x)
0
>>> cot(pi/12)
sqrt(3) + 2

See also

sin, csc, cos, sec, tan, asin, acsc, acos, asec, atan, acot, atan2

References

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

period(symbol=None)[source]
static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.csc(arg)[source]

Bases: ReciprocalTrigonometricFunction

The cosecant function.

Returns the cosecant of x (measured in radians).

Notes

See sin() for notes about automatic evaluation.

Examples

>>> from ... import csc
>>> from ...abc import x
>>> csc(x**2).diff(x)
-2*x*cot(x**2)*csc(x**2)
>>> csc(1).diff(x)
0

See also

sin, cos, sec, tan, cot, asin, acsc, acos, asec, atan, acot, atan2

References

default_assumptions = {}
fdiff(argindex=1)[source]

Returns the first derivative of the function.

period(symbol=None)[source]
static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.sec(arg)[source]

Bases: ReciprocalTrigonometricFunction

The secant function.

Returns the secant of x (measured in radians).

Notes

See sin() for notes about automatic evaluation.

Examples

>>> from ... import sec
>>> from ...abc import x
>>> sec(x**2).diff(x)
2*x*tan(x**2)*sec(x**2)
>>> sec(1).diff(x)
0

See also

sin, csc, cos, tan, cot, asin, acsc, acos, asec, atan, acot, atan2

References

default_assumptions = {}
fdiff(argindex=1)[source]

Returns the first derivative of the function.

period(symbol=None)[source]
static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.sin(arg)[source]

Bases: TrigonometricFunction

The sine function.

Returns the sine of x (measured in radians).

Notes

This function will evaluate automatically in the case x/pi is some rational number [4]_. For example, if x is a multiple of pi, pi/2, pi/3, pi/4 and pi/6.

Examples

>>> from ... import sin, pi
>>> from ...abc import x
>>> sin(x**2).diff(x)
2*x*cos(x**2)
>>> sin(1).diff(x)
0
>>> sin(pi)
0
>>> sin(pi/2)
1
>>> sin(pi/6)
1/2
>>> sin(pi/12)
-sqrt(2)/4 + sqrt(6)/4

See also

csc, cos, sec, tan, cot, asin, acsc, acos, asec, atan, acot, atan2

References

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

period(symbol=None)[source]
static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

class modelparameters.sympy.functions.elementary.trigonometric.sinc(arg)[source]

Bases: TrigonometricFunction

Represents unnormalized sinc function

Examples

>>> from ... import sinc, oo, jn, Product, Symbol
>>> from ...abc import x
>>> sinc(x)
sinc(x)
  • Automated Evaluation

>>> sinc(0)
1
>>> sinc(oo)
0
  • Differentiation

>>> sinc(x).diff()
(x*cos(x) - sin(x))/x**2
  • Series Expansion

>>> sinc(x).series()
1 - x**2/6 + x**4/120 + O(x**6)
  • As zero’th order spherical Bessel Function

>>> sinc(x).rewrite(jn)
jn(0, x)

References

default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

class modelparameters.sympy.functions.elementary.trigonometric.tan(arg)[source]

Bases: TrigonometricFunction

The tangent function.

Returns the tangent of x (measured in radians).

Notes

See sin() for notes about automatic evaluation.

Examples

>>> from ... import tan, pi
>>> from ...abc import x
>>> tan(x**2).diff(x)
2*x*(tan(x**2)**2 + 1)
>>> tan(1).diff(x)
0
>>> tan(pi/8).expand()
-1 + sqrt(2)

See also

sin, csc, cos, sec, cot, asin, acsc, acos, asec, atan, acot, atan2

References

as_real_imag(deep=True, **hints)[source]

Performs complex expansion on ‘self’ and returns a tuple containing collected both real and imaginary parts. This method can’t be confused with re() and im() functions, which does not perform complex expansion at evaluation.

However it is possible to expand both re() and im() functions and get exactly the same results as with a single call to this function.

>>> from .. import symbols, I
>>> x, y = symbols('x,y', real=True)
>>> (x + y*I).as_real_imag()
(x, y)
>>> from ..abc import z, w
>>> (z + w*I).as_real_imag()
(re(z) - im(w), re(w) + im(z))
default_assumptions = {}
classmethod eval(arg)[source]

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

Examples of eval() for the function “sign”

@classmethod def eval(cls, arg):

if arg is S.NaN:

return S.NaN

if arg is S.Zero: return S.Zero if arg.is_positive: return S.One if arg.is_negative: return S.NegativeOne if isinstance(arg, Mul):

coeff, terms = arg.as_coeff_Mul(rational=True) if coeff is not S.One:

return cls(coeff) * cls(terms)

fdiff(argindex=1)[source]

Returns the first derivative of the function.

inverse(argindex=1)[source]

Returns the inverse of this function.

period(symbol=None)[source]
static taylor_term(n, x, *previous_terms)[source]

General method for the taylor term.

This method is slow, because it differentiates n-times. Subclasses can redefine it to make it faster by using the “previous_terms”.

Module contents