modelparameters.sympy.integrals package

Submodules

modelparameters.sympy.integrals.deltafunctions module

modelparameters.sympy.integrals.deltafunctions.change_mul(node, x)[source]

Rearranges the operands of a product, bringing to front any simple DiracDelta expression.

If no simple DiracDelta expression was found, then all the DiracDelta expressions are simplified (using DiracDelta.expand(diracdelta=True, wrt=x)).

Return: (dirac, new node) Where:

o dirac is either a simple DiracDelta expression or None (if no simple

expression was found);

o new node is either a simplified DiracDelta expressions or None (if it

could not be simplified).

Examples

>>> from .. import DiracDelta, cos
>>> from .deltafunctions import change_mul
>>> from ..abc import x, y
>>> change_mul(x*y*DiracDelta(x)*cos(x), x)
(DiracDelta(x), x*y*cos(x))
>>> change_mul(x*y*DiracDelta(x**2 - 1)*cos(x), x)
(None, x*y*cos(x)*DiracDelta(x - 1)/2 + x*y*cos(x)*DiracDelta(x + 1)/2)
>>> change_mul(x*y*DiracDelta(cos(x))*cos(x), x)
(None, None)

See also

sympy.functions.special.delta_functions.DiracDelta, deltaintegrate

modelparameters.sympy.integrals.deltafunctions.deltaintegrate(f, x)[source]

The idea for integration is the following:

  • If we are dealing with a DiracDelta expression, i.e. DiracDelta(g(x)), we try to simplify it.

    If we could simplify it, then we integrate the resulting expression. We already know we can integrate a simplified expression, because only simple DiracDelta expressions are involved.

    If we couldn’t simplify it, there are two cases:

    1. The expression is a simple expression: we return the integral, taking care if we are dealing with a Derivative or with a proper DiracDelta.

    2. The expression is not simple (i.e. DiracDelta(cos(x))): we can do nothing at all.

  • If the node is a multiplication node having a DiracDelta term:

    First we expand it.

    If the expansion did work, then we try to integrate the expansion.

    If not, we try to extract a simple DiracDelta term, then we have two cases:

    1. We have a simple DiracDelta term, so we return the integral.

    2. We didn’t have a simple term, but we do have an expression with simplified DiracDelta terms, so we integrate this expression.

Examples

>>> from ..abc import x, y, z
>>> from .deltafunctions import deltaintegrate
>>> from .. import sin, cos, DiracDelta, Heaviside
>>> deltaintegrate(x*sin(x)*cos(x)*DiracDelta(x - 1), x)
sin(1)*cos(1)*Heaviside(x - 1)
>>> deltaintegrate(y**2*DiracDelta(x - z)*DiracDelta(y - z), y)
z**2*DiracDelta(x - z)*Heaviside(y - z)

See also

sympy.functions.special.delta_functions.DiracDelta, sympy.integrals.integrals.Integral

modelparameters.sympy.integrals.heurisch module

class modelparameters.sympy.integrals.heurisch.BesselTable[source]

Bases: object

Derivatives of Bessel functions of orders n and n-1 in terms of each other.

See the docstring of DiffCache.

diffs(f, n, z)[source]
has(f)[source]
class modelparameters.sympy.integrals.heurisch.DiffCache(x)[source]

Bases: object

Store for derivatives of expressions.

The standard form of the derivative of a Bessel function of order n contains two Bessel functions of orders n-1 and n+1, respectively. Such forms cannot be used in parallel Risch algorithm, because there is a linear recurrence relation between the three functions while the algorithm expects that functions and derivatives are represented in terms of algebraically independent transcendentals.

The solution is to take two of the functions, e.g., those of orders n and n-1, and to express the derivatives in terms of the pair. To guarantee that the proper form is used the two derivatives are cached as soon as one is encountered.

Derivatives of other functions are also cached at no extra cost. All derivatives are with respect to the same variable x.

get_diff(f)[source]
modelparameters.sympy.integrals.heurisch.components(f, x)[source]

Returns a set of all functional components of the given expression which includes symbols, function applications and compositions and non-integer powers. Fractional powers are collected with minimal, positive exponents.

>>> from .. import cos, sin
>>> from ..abc import x, y
>>> from .heurisch import components
>>> components(sin(x)*cos(x)**2, x)
{x, sin(x), cos(x)}

See also

heurisch

modelparameters.sympy.integrals.heurisch.heurisch(f, x, rewrite=False, hints=None, mappings=None, retries=3, degree_offset=0, unnecessary_permutations=None)[source]

Compute indefinite integral using heuristic Risch algorithm.

This is a heuristic approach to indefinite integration in finite terms using the extended heuristic (parallel) Risch algorithm, based on Manuel Bronstein’s “Poor Man’s Integrator”.

The algorithm supports various classes of functions including transcendental elementary or special functions like Airy, Bessel, Whittaker and Lambert.

Note that this algorithm is not a decision procedure. If it isn’t able to compute the antiderivative for a given function, then this is not a proof that such a functions does not exist. One should use recursive Risch algorithm in such case. It’s an open question if this algorithm can be made a full decision procedure.

This is an internal integrator procedure. You should use toplevel ‘integrate’ function in most cases, as this procedure needs some preprocessing steps and otherwise may fail.

Specification

heurisch(f, x, rewrite=False, hints=None)

where

f : expression x : symbol

rewrite -> force rewrite ‘f’ in terms of ‘tan’ and ‘tanh’ hints -> a list of functions that may appear in anti-derivate

  • hints = None –> no suggestions at all

  • hints = [ ] –> try to figure out

  • hints = [f1, …, fn] –> we know better

Examples

>>> from .. import tan
>>> from .heurisch import heurisch
>>> from ..abc import x, y
>>> heurisch(y*tan(x), x)
y*log(tan(x)**2 + 1)/2

See Manuel Bronstein’s “Poor Man’s Integrator”:

[1] http://www-sop.inria.fr/cafe/Manuel.Bronstein/pmint/index.html

For more information on the implemented algorithm refer to:

[2] K. Geddes, L. Stefanus, On the Risch-Norman Integration

Method and its Implementation in Maple, Proceedings of ISSAC’89, ACM Press, 212-217.

[3] J. H. Davenport, On the Parallel Risch Algorithm (I),

Proceedings of EUROCAM’82, LNCS 144, Springer, 144-157.

[4] J. H. Davenport, On the Parallel Risch Algorithm (III):

Use of Tangents, SIGSAM Bulletin 16 (1982), 3-6.

[5] J. H. Davenport, B. M. Trager, On the Parallel Risch

Algorithm (II), ACM Transactions on Mathematical Software 11 (1985), 356-362.

See also

sympy.integrals.integrals.Integral.doit, sympy.integrals.integrals.Integral, components

modelparameters.sympy.integrals.heurisch.heurisch_wrapper(f, x, rewrite=False, hints=None, mappings=None, retries=3, degree_offset=0, unnecessary_permutations=None)[source]

A wrapper around the heurisch integration algorithm.

This method takes the result from heurisch and checks for poles in the denominator. For each of these poles, the integral is reevaluated, and the final integration result is given in terms of a Piecewise.

Examples

>>> from ..core import symbols
>>> from ..functions import cos
>>> from .heurisch import heurisch, heurisch_wrapper
>>> n, x = symbols('n x')
>>> heurisch(cos(n*x), x)
sin(n*x)/n
>>> heurisch_wrapper(cos(n*x), x)
Piecewise((x, Eq(n, 0)), (sin(n*x)/n, True))

See also

heurisch

modelparameters.sympy.integrals.integrals module

class modelparameters.sympy.integrals.integrals.Integral(function, *symbols, **assumptions)[source]

Bases: AddWithLimits

Represents unevaluated integral.

as_sum(n, method='midpoint')[source]

Approximates the definite integral by a sum.

method … one of: left, right, midpoint, trapezoid

These are all basically the rectangle method [1], the only difference is where the function value is taken in each interval to define the rectangle.

[1] http://en.wikipedia.org/wiki/Rectangle_method

Examples

>>> from .. import sin, sqrt
>>> from ..abc import x
>>> from ..integrals import Integral
>>> e = Integral(sin(x), (x, 3, 7))
>>> e
Integral(sin(x), (x, 3, 7))

For demonstration purposes, this interval will only be split into 2 regions, bounded by [3, 5] and [5, 7].

The left-hand rule uses function evaluations at the left of each interval:

>>> e.as_sum(2, 'left')
2*sin(5) + 2*sin(3)

The midpoint rule uses evaluations at the center of each interval:

>>> e.as_sum(2, 'midpoint')
2*sin(4) + 2*sin(6)

The right-hand rule uses function evaluations at the right of each interval:

>>> e.as_sum(2, 'right')
2*sin(5) + 2*sin(7)

The trapezoid rule uses function evaluations on both sides of the intervals. This is equivalent to taking the average of the left and right hand rule results:

>>> e.as_sum(2, 'trapezoid')
2*sin(5) + sin(3) + sin(7)
>>> (e.as_sum(2, 'left') + e.as_sum(2, 'right'))/2 == _
True

All but the trapexoid method may be used when dealing with a function with a discontinuity. Here, the discontinuity at x = 0 can be avoided by using the midpoint or right-hand method:

>>> e = Integral(1/sqrt(x), (x, 0, 1))
>>> e.as_sum(5).n(4)
1.730
>>> e.as_sum(10).n(4)
1.809
>>> e.doit().n(4)  # the actual value is 2
2.000

The left- or trapezoid method will encounter the discontinuity and return oo:

>>> e.as_sum(5, 'left')
oo
>>> e.as_sum(5, 'trapezoid')
oo

See also

Integral.doit

Perform the integration using any hints

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

Perform the integration using any hints given.

Examples

>>> from .. import Integral
>>> from ..abc import x, i
>>> Integral(x**i, (i, 1, 3)).doit()
Piecewise((2, Eq(log(x), 0)), (x**3/log(x) - x/log(x), True))

See also

sympy.integrals.trigonometry.trigintegrate, sympy.integrals.risch.heurisch, sympy.integrals.rationaltools.ratint

as_sum

Approximate the integral using a sum

property free_symbols

This method returns the symbols that will exist when the integral is evaluated. This is useful if one is trying to determine whether an integral depends on a certain symbol or not.

Examples

>>> from .. import Integral
>>> from ..abc import x, y
>>> Integral(x, (x, y, 1)).free_symbols
{y}

See also

function, limits, variables

is_commutative
transform(x, u)[source]

Performs a change of variables from x to u using the relationship given by x and u which will define the transformations f and F (which are inverses of each other) as follows:

  1. If x is a Symbol (which is a variable of integration) then u will be interpreted as some function, f(u), with inverse F(u). This, in effect, just makes the substitution of x with f(x).

  2. If u is a Symbol then x will be interpreted as some function, F(x), with inverse f(u). This is commonly referred to as u-substitution.

Once f and F have been identified, the transformation is made as follows:

\[\int_a^b x \mathrm{d}x \rightarrow \int_{F(a)}^{F(b)} f(x) \frac{\mathrm{d}}{\mathrm{d}x}\]

where F(x) is the inverse of f(x) and the limits and integrand have been corrected so as to retain the same value after integration.

Notes

The mappings, F(x) or f(u), must lead to a unique integral. Linear or rational linear expression, 2*x, 1/x and sqrt(x), will always work; quadratic expressions like x**2 - 1 are acceptable as long as the resulting integrand does not depend on the sign of the solutions (see examples).

The integral will be returned unchanged if x is not a variable of integration.

x must be (or contain) only one of of the integration variables. If u has more than one free symbol then it should be sent as a tuple (u, uvar) where uvar identifies which variable is replacing the integration variable. XXX can it contain another integration variable?

Examples

>>> from ..abc import a, b, c, d, x, u, y
>>> from .. import Integral, S, cos, sqrt
>>> i = Integral(x*cos(x**2 - 1), (x, 0, 1))

transform can change the variable of integration

>>> i.transform(x, u)
Integral(u*cos(u**2 - 1), (u, 0, 1))

transform can perform u-substitution as long as a unique integrand is obtained:

>>> i.transform(x**2 - 1, u)
Integral(cos(u)/2, (u, -1, 0))

This attempt fails because x = +/-sqrt(u + 1) and the sign does not cancel out of the integrand:

>>> Integral(cos(x**2 - 1), (x, 0, 1)).transform(x**2 - 1, u)
Traceback (most recent call last):
...
ValueError:
The mapping between F(x) and f(u) did not give a unique integrand.

transform can do a substitution. Here, the previous result is transformed back into the original expression using “u-substitution”:

>>> ui = _
>>> _.transform(sqrt(u + 1), x) == i
True

We can accomplish the same with a regular substitution:

>>> ui.transform(u, x**2 - 1) == i
True

If the x does not contain a symbol of integration then the integral will be returned unchanged. Integral i does not have an integration variable a so no change is made:

>>> i.transform(a, x) == i
True

When u has more than one free symbol the symbol that is replacing x must be identified by passing u as a tuple:

>>> Integral(x, (x, 0, 1)).transform(x, (u + a, u))
Integral(a + u, (u, -a, -a + 1))
>>> Integral(x, (x, 0, 1)).transform(x, (u + a, a))
Integral(a + u, (a, -u, -u + 1))

See also

variables

Lists the integration variables

as_dummy

Replace integration variables with dummy ones

modelparameters.sympy.integrals.integrals.integrate(f, var, ...)[source]

Compute definite or indefinite integral of one or more variables using Risch-Norman algorithm and table lookup. This procedure is able to handle elementary algebraic and transcendental functions and also a huge class of special functions, including Airy, Bessel, Whittaker and Lambert.

var can be:

  • a symbol – indefinite integration

  • a tuple (symbol, a) – indefinite integration with result

    given with a replacing symbol

  • a tuple (symbol, a, b) – definite integration

Several variables can be specified, in which case the result is multiple integration. (If var is omitted and the integrand is univariate, the indefinite integral in that variable will be performed.)

Indefinite integrals are returned without terms that are independent of the integration variables. (see examples)

Definite improper integrals often entail delicate convergence conditions. Pass conds=’piecewise’, ‘separate’ or ‘none’ to have these returned, respectively, as a Piecewise function, as a separate result (i.e. result will be a tuple), or not at all (default is ‘piecewise’).

Strategy

SymPy uses various approaches to definite integration. One method is to find an antiderivative for the integrand, and then use the fundamental theorem of calculus. Various functions are implemented to integrate polynomial, rational and trigonometric functions, and integrands containing DiracDelta terms.

SymPy also implements the part of the Risch algorithm, which is a decision procedure for integrating elementary functions, i.e., the algorithm can either find an elementary antiderivative, or prove that one does not exist. There is also a (very successful, albeit somewhat slow) general implementation of the heuristic Risch algorithm. This algorithm will eventually be phased out as more of the full Risch algorithm is implemented. See the docstring of Integral._eval_integral() for more details on computing the antiderivative using algebraic methods.

The option risch=True can be used to use only the (full) Risch algorithm. This is useful if you want to know if an elementary function has an elementary antiderivative. If the indefinite Integral returned by this function is an instance of NonElementaryIntegral, that means that the Risch algorithm has proven that integral to be non-elementary. Note that by default, additional methods (such as the Meijer G method outlined below) are tried on these integrals, as they may be expressible in terms of special functions, so if you only care about elementary answers, use risch=True. Also note that an unevaluated Integral returned by this function is not necessarily a NonElementaryIntegral, even with risch=True, as it may just be an indication that the particular part of the Risch algorithm needed to integrate that function is not yet implemented.

Another family of strategies comes from re-writing the integrand in terms of so-called Meijer G-functions. Indefinite integrals of a single G-function can always be computed, and the definite integral of a product of two G-functions can be computed from zero to infinity. Various strategies are implemented to rewrite integrands as G-functions, and use this information to compute integrals (see the meijerint module).

The option manual=True can be used to use only an algorithm that tries to mimic integration by hand. This algorithm does not handle as many integrands as the other algorithms implemented but may return results in a more familiar form. The manualintegrate module has functions that return the steps used (see the module docstring for more information).

In general, the algebraic methods work best for computing antiderivatives of (possibly complicated) combinations of elementary functions. The G-function methods work best for computing definite integrals from zero to infinity of moderately complicated combinations of special functions, or indefinite integrals of very simple combinations of special functions.

The strategy employed by the integration code is as follows:

  • If computing a definite integral, and both limits are real, and at least one limit is +- oo, try the G-function method of definite integration first.

  • Try to find an antiderivative, using all available methods, ordered by performance (that is try fastest method first, slowest last; in particular polynomial integration is tried first, Meijer G-functions second to last, and heuristic Risch last).

  • If still not successful, try G-functions irrespective of the limits.

The option meijerg=True, False, None can be used to, respectively: always use G-function methods and no others, never use G-function methods, or use all available methods (in order as described above). It defaults to None.

Examples

>>> from .. import integrate, log, exp, oo
>>> from ..abc import a, x, y
>>> integrate(x*y, x)
x**2*y/2
>>> integrate(log(x), x)
x*log(x) - x
>>> integrate(log(x), (x, 1, a))
a*log(a) - a + 1
>>> integrate(x)
x**2/2

Terms that are independent of x are dropped by indefinite integration:

>>> from .. import sqrt
>>> integrate(sqrt(1 + x), (x, 0, x))
2*(x + 1)**(3/2)/3 - 2/3
>>> integrate(sqrt(1 + x), x)
2*(x + 1)**(3/2)/3
>>> integrate(x*y)
Traceback (most recent call last):
...
ValueError: specify integration variables to integrate x*y

Note that integrate(x) syntax is meant only for convenience in interactive sessions and should be avoided in library code.

>>> integrate(x**a*exp(-x), (x, 0, oo)) # same as conds='piecewise'
Piecewise((gamma(a + 1), -re(a) < 1),
    (Integral(x**a*exp(-x), (x, 0, oo)), True))
>>> integrate(x**a*exp(-x), (x, 0, oo), conds='none')
gamma(a + 1)
>>> integrate(x**a*exp(-x), (x, 0, oo), conds='separate')
(gamma(a + 1), -re(a) < 1)
modelparameters.sympy.integrals.integrals.line_integrate(field, Curve, variables)[source]

Compute the line integral.

Examples

>>> from .. import Curve, line_integrate, E, ln
>>> from ..abc import x, y, t
>>> C = Curve([E**t + 1, E**t - 1], (t, 0, ln(2)))
>>> line_integrate(x + y, C, [x, y])
3*sqrt(2)

See also

integrate, Integral

modelparameters.sympy.integrals.manualintegrate module

Integration method that emulates by-hand techniques.

This module also provides functionality to get the steps used to evaluate a particular integral, in the integral_steps function. This will return nested namedtuples representing the integration rules used. The manualintegrate function computes the integral using those steps given an integrand; given the steps, _manualintegrate will evaluate them.

The integrator can be extended with new heuristics and evaluation techniques. To do so, write a function that accepts an IntegralInfo object and returns either a namedtuple representing a rule or None. Then, write another function that accepts the namedtuple’s fields and returns the antiderivative, and decorate it with @evaluates(namedtuple_type). If the new technique requires a new match, add the key and call to the antiderivative function to integral_steps. To enable simple substitutions, add the match to find_substitutions.

class modelparameters.sympy.integrals.manualintegrate.AddRule(substeps, context, symbol)

Bases: tuple

context

Alias for field number 1

substeps

Alias for field number 0

symbol

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.AlternativeRule(alternatives, context, symbol)

Bases: tuple

alternatives

Alias for field number 0

context

Alias for field number 1

symbol

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.ArccothRule(a, b, c, context, symbol)

Bases: tuple

a

Alias for field number 0

b

Alias for field number 1

c

Alias for field number 2

context

Alias for field number 3

symbol

Alias for field number 4

class modelparameters.sympy.integrals.manualintegrate.ArcsinRule(context, symbol)

Bases: tuple

context

Alias for field number 0

symbol

Alias for field number 1

class modelparameters.sympy.integrals.manualintegrate.ArctanRule(a, b, c, context, symbol)

Bases: tuple

a

Alias for field number 0

b

Alias for field number 1

c

Alias for field number 2

context

Alias for field number 3

symbol

Alias for field number 4

class modelparameters.sympy.integrals.manualintegrate.ArctanhRule(a, b, c, context, symbol)

Bases: tuple

a

Alias for field number 0

b

Alias for field number 1

c

Alias for field number 2

context

Alias for field number 3

symbol

Alias for field number 4

class modelparameters.sympy.integrals.manualintegrate.ConstantRule(constant, context, symbol)

Bases: tuple

constant

Alias for field number 0

context

Alias for field number 1

symbol

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.ConstantTimesRule(constant, other, substep, context, symbol)

Bases: tuple

constant

Alias for field number 0

context

Alias for field number 3

other

Alias for field number 1

substep

Alias for field number 2

symbol

Alias for field number 4

class modelparameters.sympy.integrals.manualintegrate.CyclicPartsRule(parts_rules, coefficient, context, symbol)

Bases: tuple

coefficient

Alias for field number 1

context

Alias for field number 2

parts_rules

Alias for field number 0

symbol

Alias for field number 3

class modelparameters.sympy.integrals.manualintegrate.DerivativeRule(context, symbol)

Bases: tuple

context

Alias for field number 0

symbol

Alias for field number 1

class modelparameters.sympy.integrals.manualintegrate.DontKnowRule(context, symbol)

Bases: tuple

context

Alias for field number 0

symbol

Alias for field number 1

class modelparameters.sympy.integrals.manualintegrate.ExpRule(base, exp, context, symbol)

Bases: tuple

base

Alias for field number 0

context

Alias for field number 2

exp

Alias for field number 1

symbol

Alias for field number 3

class modelparameters.sympy.integrals.manualintegrate.HeavisideRule(harg, ibnd, substep, context, symbol)

Bases: tuple

context

Alias for field number 3

harg

Alias for field number 0

ibnd

Alias for field number 1

substep

Alias for field number 2

symbol

Alias for field number 4

class modelparameters.sympy.integrals.manualintegrate.IntegralInfo(integrand, symbol)

Bases: tuple

integrand

Alias for field number 0

symbol

Alias for field number 1

class modelparameters.sympy.integrals.manualintegrate.InverseHyperbolicRule(func, context, symbol)

Bases: tuple

context

Alias for field number 1

func

Alias for field number 0

symbol

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.PartsRule(u, dv, v_step, second_step, context, symbol)

Bases: tuple

context

Alias for field number 4

dv

Alias for field number 1

second_step

Alias for field number 3

symbol

Alias for field number 5

u

Alias for field number 0

v_step

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.PiecewiseRule(subfunctions, context, symbol)

Bases: tuple

context

Alias for field number 1

subfunctions

Alias for field number 0

symbol

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.PowerRule(base, exp, context, symbol)

Bases: tuple

base

Alias for field number 0

context

Alias for field number 2

exp

Alias for field number 1

symbol

Alias for field number 3

class modelparameters.sympy.integrals.manualintegrate.ReciprocalRule(func, context, symbol)

Bases: tuple

context

Alias for field number 1

func

Alias for field number 0

symbol

Alias for field number 2

class modelparameters.sympy.integrals.manualintegrate.RewriteRule(rewritten, substep, context, symbol)

Bases: tuple

context

Alias for field number 2

rewritten

Alias for field number 0

substep

Alias for field number 1

symbol

Alias for field number 3

modelparameters.sympy.integrals.manualintegrate.Rule(name, props='')[source]
class modelparameters.sympy.integrals.manualintegrate.TrigRule(func, arg, context, symbol)

Bases: tuple

arg

Alias for field number 1

context

Alias for field number 2

func

Alias for field number 0

symbol

Alias for field number 3

class modelparameters.sympy.integrals.manualintegrate.TrigSubstitutionRule(theta, func, rewritten, substep, restriction, context, symbol)

Bases: tuple

context

Alias for field number 5

func

Alias for field number 1

restriction

Alias for field number 4

rewritten

Alias for field number 2

substep

Alias for field number 3

symbol

Alias for field number 6

theta

Alias for field number 0

class modelparameters.sympy.integrals.manualintegrate.URule(u_var, u_func, constant, substep, context, symbol)

Bases: tuple

constant

Alias for field number 2

context

Alias for field number 4

substep

Alias for field number 3

symbol

Alias for field number 5

u_func

Alias for field number 1

u_var

Alias for field number 0

modelparameters.sympy.integrals.manualintegrate.add_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.alternatives(*rules)[source]

Strategy that makes an AlternativeRule out of multiple possible results.

modelparameters.sympy.integrals.manualintegrate.cancel_rule(integral)
modelparameters.sympy.integrals.manualintegrate.constant_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.contains_dont_know(rule)[source]
modelparameters.sympy.integrals.manualintegrate.cotcsc_cotodd(args)
modelparameters.sympy.integrals.manualintegrate.cotcsc_cotodd_condition(args)
modelparameters.sympy.integrals.manualintegrate.cotcsc_csceven(args)
modelparameters.sympy.integrals.manualintegrate.cotcsc_csceven_condition(args)
modelparameters.sympy.integrals.manualintegrate.cotcsc_pattern(symbol)[source]
modelparameters.sympy.integrals.manualintegrate.derivative_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.distribute_expand_rule(integral)
modelparameters.sympy.integrals.manualintegrate.eval_add(substeps, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_alternative(alternatives, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_arccoth(a, b, c, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_arcsin(integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_arctan(a, b, c, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_arctanh(a, b, c, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_constant(constant, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_constanttimes(constant, other, substep, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_cyclicparts(parts_rules, coefficient, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_derivativerule(integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_dontknowrule(integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_exp(base, exp, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_heaviside(harg, ibnd, substep, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_inversehyperbolic(func, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_parts(u, dv, v_step, second_step, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_piecewise(substeps, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_power(base, exp, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_reciprocal(func, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_rewrite(rewritten, substep, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_trig(func, arg, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_trigsubstitution(theta, func, rewritten, substep, restriction, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.eval_u(u_var, u_func, constant, substep, integrand, symbol)[source]
modelparameters.sympy.integrals.manualintegrate.evaluates(rule)[source]
modelparameters.sympy.integrals.manualintegrate.exp_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.fallback_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.find_substitutions(integrand, symbol, u_var)[source]
modelparameters.sympy.integrals.manualintegrate.heaviside_pattern(symbol)[source]
modelparameters.sympy.integrals.manualintegrate.heaviside_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.integral_steps(integrand, symbol, **options)[source]

Returns the steps needed to compute an integral.

This function attempts to mirror what a student would do by hand as closely as possible.

SymPy Gamma uses this to provide a step-by-step explanation of an integral. The code it uses to format the results of this function can be found at https://github.com/sympy/sympy_gamma/blob/master/app/logic/intsteps.py.

Examples

>>> from .. import exp, sin, cos
>>> from .manualintegrate import integral_steps
>>> from ..abc import x
>>> print(repr(integral_steps(exp(x) / (1 + exp(2 * x)), x)))     
URule(u_var=_u, u_func=exp(x), constant=1,
substep=PiecewiseRule(subfunctions=[(ArctanRule(a=1, b=1, c=1, context=1/(_u**2 + 1), symbol=_u), True),
    (ArccothRule(a=1, b=1, c=1, context=1/(_u**2 + 1), symbol=_u), False),
    (ArctanhRule(a=1, b=1, c=1, context=1/(_u**2 + 1), symbol=_u), False)],
context=1/(_u**2 + 1), symbol=_u), context=exp(x)/(exp(2*x) + 1), symbol=x)
>>> print(repr(integral_steps(sin(x), x)))     
TrigRule(func='sin', arg=x, context=sin(x), symbol=x)
>>> print(repr(integral_steps((x**2 + 3)**2 , x)))     
RewriteRule(rewritten=x**4 + 6*x**2 + 9,
substep=AddRule(substeps=[PowerRule(base=x, exp=4, context=x**4, symbol=x),
    ConstantTimesRule(constant=6, other=x**2,
        substep=PowerRule(base=x, exp=2, context=x**2, symbol=x),
            context=6*x**2, symbol=x),
    ConstantRule(constant=9, context=9, symbol=x)],
context=x**4 + 6*x**2 + 9, symbol=x), context=(x**2 + 3)**2, symbol=x)
Returns:

rule – The first step; most rules have substeps that must also be considered. These substeps can be evaluated using manualintegrate to obtain a result.

Return type:

namedtuple

modelparameters.sympy.integrals.manualintegrate.inverse_trig_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.make_wilds(symbol)[source]
modelparameters.sympy.integrals.manualintegrate.manual_diff(f, symbol)[source]

Derivative of f in form expected by find_substitutions

SymPy’s derivatives for some trig functions (like cot) aren’t in a form that works well with finding substitutions; this replaces the derivatives for those particular forms with something that works better.

modelparameters.sympy.integrals.manualintegrate.manualintegrate(f, var)[source]

Compute indefinite integral of a single variable using an algorithm that resembles what a student would do by hand.

Unlike integrate, var can only be a single symbol.

Examples

>>> from .. import sin, cos, tan, exp, log, integrate
>>> from .manualintegrate import manualintegrate
>>> from ..abc import x
>>> manualintegrate(1 / x, x)
log(x)
>>> integrate(1/x)
log(x)
>>> manualintegrate(log(x), x)
x*log(x) - x
>>> integrate(log(x))
x*log(x) - x
>>> manualintegrate(exp(x) / (1 + exp(2 * x)), x)
atan(exp(x))
>>> integrate(exp(x) / (1 + exp(2 * x)))
RootSum(4*_z**2 + 1, Lambda(_i, _i*log(2*_i + exp(x))))
>>> manualintegrate(cos(x)**4 * sin(x), x)
-cos(x)**5/5
>>> integrate(cos(x)**4 * sin(x), x)
-cos(x)**5/5
>>> manualintegrate(cos(x)**4 * sin(x)**3, x)
cos(x)**7/7 - cos(x)**5/5
>>> integrate(cos(x)**4 * sin(x)**3, x)
cos(x)**7/7 - cos(x)**5/5
>>> manualintegrate(tan(x), x)
-log(cos(x))
>>> integrate(tan(x), x)
-log(sin(x)**2 - 1)/2

See also

sympy.integrals.integrals.integrate, sympy.integrals.integrals.Integral.doit, sympy.integrals.integrals.Integral

modelparameters.sympy.integrals.manualintegrate.mul_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.multiplexer(conditions)[source]

Apply the rule that matches the condition, else None

modelparameters.sympy.integrals.manualintegrate.partial_fractions_rule(integral)
modelparameters.sympy.integrals.manualintegrate.parts_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.power_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.proxy_rewriter(condition, rewrite)[source]

Strategy that rewrites an integrand based on some other criteria.

modelparameters.sympy.integrals.manualintegrate.quadratic_denom_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.rewriter(condition, rewrite)[source]

Strategy that rewrites an integrand.

modelparameters.sympy.integrals.manualintegrate.rewrites_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.root_mul_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.sincos_botheven(args)
modelparameters.sympy.integrals.manualintegrate.sincos_botheven_condition(args)
modelparameters.sympy.integrals.manualintegrate.sincos_cosodd(args)
modelparameters.sympy.integrals.manualintegrate.sincos_cosodd_condition(args)
modelparameters.sympy.integrals.manualintegrate.sincos_pattern(symbol)[source]
modelparameters.sympy.integrals.manualintegrate.sincos_sinodd(args)
modelparameters.sympy.integrals.manualintegrate.sincos_sinodd_condition(args)
modelparameters.sympy.integrals.manualintegrate.substitution_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.tan_tansquared(args)
modelparameters.sympy.integrals.manualintegrate.tan_tansquared_condition(args)
modelparameters.sympy.integrals.manualintegrate.tansec_pattern(symbol)[source]
modelparameters.sympy.integrals.manualintegrate.tansec_seceven(args)
modelparameters.sympy.integrals.manualintegrate.tansec_seceven_condition(args)
modelparameters.sympy.integrals.manualintegrate.tansec_tanodd(args)
modelparameters.sympy.integrals.manualintegrate.tansec_tanodd_condition(args)
modelparameters.sympy.integrals.manualintegrate.trig_cotcsc_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.trig_powers_products_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.trig_product_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.trig_rewriter(rewrite)[source]
modelparameters.sympy.integrals.manualintegrate.trig_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.trig_sincos_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.trig_substitution_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.trig_tansec_rule(integral)[source]
modelparameters.sympy.integrals.manualintegrate.uncurry(func)[source]

modelparameters.sympy.integrals.meijerint module

Integrate functions by rewriting them as Meijer G-functions.

There are three user-visible functions that can be used by other parts of the sympy library to solve various integration problems:

  • meijerint_indefinite

  • meijerint_definite

  • meijerint_inversion

They can be used to compute, respectively, indefinite integrals, definite integrals over intervals of the real line, and inverse laplace-type integrals (from c-I*oo to c+I*oo). See the respective docstrings for details.

The main references for this are:

[L] Luke, Y. L. (1969), The Special Functions and Their Approximations,

Volume 1

[R] Kelly B. Roach. Meijer G Function Representations.

In: Proceedings of the 1997 International Symposium on Symbolic and Algebraic Computation, pages 205-211, New York, 1997. ACM.

[P] A. P. Prudnikov, Yu. A. Brychkov and O. I. Marichev (1990).

Integrals and Series: More Special Functions, Vol. 3,. Gordon and Breach Science Publisher

modelparameters.sympy.integrals.meijerint.meijerint_definite(f, x, a, b)[source]

Integrate f over the interval [a, b], by rewriting it as a product of two G functions, or as a single G function.

Return res, cond, where cond are convergence conditions.

Examples

>>> from .meijerint import meijerint_definite
>>> from .. import exp, oo
>>> from ..abc import x
>>> meijerint_definite(exp(-x**2), x, -oo, oo)
(sqrt(pi), True)

This function is implemented as a succession of functions meijerint_definite, _meijerint_definite_2, _meijerint_definite_3, _meijerint_definite_4. Each function in the list calls the next one (presumably) several times. This means that calling meijerint_definite can be very costly.

modelparameters.sympy.integrals.meijerint.meijerint_indefinite(f, x)[source]

Compute an indefinite integral of f by rewriting it as a G function.

Examples

>>> from .meijerint import meijerint_indefinite
>>> from .. import sin
>>> from ..abc import x
>>> meijerint_indefinite(sin(x), x)
-cos(x)
modelparameters.sympy.integrals.meijerint.meijerint_inversion(f, x, t)[source]

Compute the inverse laplace transform :math:int_{c+iinfty}^{c-iinfty} f(x) e^{tx) dx, for real c larger than the real part of all singularities of f. Note that t is always assumed real and positive.

Return None if the integral does not exist or could not be evaluated.

Examples

>>> from ..abc import x, t
>>> from .meijerint import meijerint_inversion
>>> meijerint_inversion(1/x, x, t)
Heaviside(t)

modelparameters.sympy.integrals.meijerint_doc module

Elementary functions:

\[\begin{split}a = a {G_{1, 1}^{1, 0}\left(\begin{matrix} & 1 \\0 & \end{matrix} \middle| {z} \right)} + a {G_{1, 1}^{0, 1}\left(\begin{matrix} 1 & \\ & 0 \end{matrix} \middle| {z} \right)}\end{split}\]
\[\begin{split}\left(z^{q} p + b\right)^{- a} = \frac{b^{- a}}{\Gamma{\left(a \right)}} {G_{1, 1}^{1, 1}\left(\begin{matrix} - a + 1 & \\0 & \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)}\end{split}\]
\[\begin{split}\frac{- b^{a} + \left(z^{q} p\right)^{a}}{z^{q} p - b} = \frac{1}{\pi} b^{a - 1} {G_{2, 2}^{2, 2}\left(\begin{matrix} 0, a & \\0, a & \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)} \sin{\left (\pi a \right )}\end{split}\]
\[\begin{split}\left(a + \sqrt{z^{q} p + a^{2}}\right)^{b} = - \frac{a^{b} b}{2 \sqrt{\pi}} {G_{2, 2}^{1, 2}\left(\begin{matrix} \frac{b}{2} + \frac{1}{2}, \frac{b}{2} + 1 & \\0 & b \end{matrix} \middle| {\frac{z^{q} p}{a^{2}}} \right)}\end{split}\]
\[\begin{split}\left(- a + \sqrt{z^{q} p + a^{2}}\right)^{b} = \frac{a^{b} b}{2 \sqrt{\pi}} {G_{2, 2}^{1, 2}\left(\begin{matrix} \frac{b}{2} + \frac{1}{2}, \frac{b}{2} + 1 & \\b & 0 \end{matrix} \middle| {\frac{z^{q} p}{a^{2}}} \right)}\end{split}\]
\[\begin{split}\frac{\left(a + \sqrt{z^{q} p + a^{2}}\right)^{b}}{\sqrt{z^{q} p + a^{2}}} = \frac{1}{\sqrt{\pi}} a^{b - 1} {G_{2, 2}^{1, 2}\left(\begin{matrix} \frac{b}{2} + \frac{1}{2}, \frac{b}{2} & \\0 & b \end{matrix} \middle| {\frac{z^{q} p}{a^{2}}} \right)}\end{split}\]
\[\begin{split}\frac{\left(- a + \sqrt{z^{q} p + a^{2}}\right)^{b}}{\sqrt{z^{q} p + a^{2}}} = \frac{1}{\sqrt{\pi}} a^{b - 1} {G_{2, 2}^{1, 2}\left(\begin{matrix} \frac{b}{2} + \frac{1}{2}, \frac{b}{2} & \\b & 0 \end{matrix} \middle| {\frac{z^{q} p}{a^{2}}} \right)}\end{split}\]
\[\begin{split}\left(z^{\frac{q}{2}} \sqrt{p} + \sqrt{z^{q} p + a}\right)^{b} = - \frac{a^{\frac{b}{2}} b}{2 \sqrt{\pi}} {G_{2, 2}^{2, 1}\left(\begin{matrix} \frac{b}{2} + 1 & - \frac{b}{2} + 1 \\0, \frac{1}{2} & \end{matrix} \middle| {\frac{z^{q} p}{a}} \right)}\end{split}\]
\[\begin{split}\left(- z^{\frac{q}{2}} \sqrt{p} + \sqrt{z^{q} p + a}\right)^{b} = \frac{a^{\frac{b}{2}} b}{2 \sqrt{\pi}} {G_{2, 2}^{2, 1}\left(\begin{matrix} - \frac{b}{2} + 1 & \frac{b}{2} + 1 \\0, \frac{1}{2} & \end{matrix} \middle| {\frac{z^{q} p}{a}} \right)}\end{split}\]
\[\begin{split}\frac{\left(z^{\frac{q}{2}} \sqrt{p} + \sqrt{z^{q} p + a}\right)^{b}}{\sqrt{z^{q} p + a}} = \frac{1}{\sqrt{\pi}} a^{\frac{b}{2} - \frac{1}{2}} {G_{2, 2}^{2, 1}\left(\begin{matrix} \frac{b}{2} + \frac{1}{2} & - \frac{b}{2} + \frac{1}{2} \\0, \frac{1}{2} & \end{matrix} \middle| {\frac{z^{q} p}{a}} \right)}\end{split}\]
\[\begin{split}\frac{\left(- z^{\frac{q}{2}} \sqrt{p} + \sqrt{z^{q} p + a}\right)^{b}}{\sqrt{z^{q} p + a}} = \frac{1}{\sqrt{\pi}} a^{\frac{b}{2} - \frac{1}{2}} {G_{2, 2}^{2, 1}\left(\begin{matrix} - \frac{b}{2} + \frac{1}{2} & \frac{b}{2} + \frac{1}{2} \\0, \frac{1}{2} & \end{matrix} \middle| {\frac{z^{q} p}{a}} \right)}\end{split}\]

Functions involving left|{z^{q} p - b}right|:

\[\begin{split}\left|{z^{q} p - b}\right|^{- a} = 2 {G_{2, 2}^{1, 1}\left(\begin{matrix} - a + 1 & - \frac{a}{2} + \frac{1}{2} \\0 & - \frac{a}{2} + \frac{1}{2} \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)} \sin{\left (\frac{\pi a}{2} \right )} \left|{b}\right|^{- a} \Gamma{\left(- a + 1 \right)},\text{ if } \Re{\left(a\right)} < 1\end{split}\]

Functions involving operatorname{Chi}{left (z^{q} p right )}:

\[\begin{split}\operatorname{Chi}{\left (z^{q} p \right )} = - \frac{\pi^{\frac{3}{2}}}{2} {G_{2, 4}^{2, 0}\left(\begin{matrix} & \frac{1}{2}, 1 \\0, 0 & \frac{1}{2}, \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving operatorname{Ci}{left (z^{q} p right )}:

\[\begin{split}\operatorname{Ci}{\left (z^{q} p \right )} = - \frac{\sqrt{\pi}}{2} {G_{1, 3}^{2, 0}\left(\begin{matrix} & 1 \\0, 0 & \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving operatorname{Ei}{left (z^{q} p right )}:

\[\begin{split}\operatorname{Ei}{\left (z^{q} p \right )} = - i \pi {G_{1, 1}^{1, 0}\left(\begin{matrix} & 1 \\0 & \end{matrix} \middle| {z} \right)} - {G_{1, 2}^{2, 0}\left(\begin{matrix} & 1 \\0, 0 & \end{matrix} \middle| {z^{q} p e^{i \pi}} \right)} - i \pi {G_{1, 1}^{0, 1}\left(\begin{matrix} 1 & \\ & 0 \end{matrix} \middle| {z} \right)}\end{split}\]

Functions involving thetaleft(z^{q} p - bright):

\[\begin{split}\left(z^{q} p - b\right)^{a - 1} \theta\left(z^{q} p - b\right) = b^{a - 1} {G_{1, 1}^{0, 1}\left(\begin{matrix} a & \\ & 0 \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)} \Gamma{\left(a \right)},\text{ if } b > 0\end{split}\]
\[\begin{split}\left(- z^{q} p + b\right)^{a - 1} \theta\left(- z^{q} p + b\right) = b^{a - 1} {G_{1, 1}^{1, 0}\left(\begin{matrix} & a \\0 & \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)} \Gamma{\left(a \right)},\text{ if } b > 0\end{split}\]
\[\begin{split}\left(z^{q} p - b\right)^{a - 1} \theta\left(z - \left(\frac{b}{p}\right)^{\frac{1}{q}}\right) = b^{a - 1} {G_{1, 1}^{0, 1}\left(\begin{matrix} a & \\ & 0 \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)} \Gamma{\left(a \right)},\text{ if } b > 0\end{split}\]
\[\begin{split}\left(- z^{q} p + b\right)^{a - 1} \theta\left(- z + \left(\frac{b}{p}\right)^{\frac{1}{q}}\right) = b^{a - 1} {G_{1, 1}^{1, 0}\left(\begin{matrix} & a \\0 & \end{matrix} \middle| {\frac{z^{q} p}{b}} \right)} \Gamma{\left(a \right)},\text{ if } b > 0\end{split}\]

Functions involving thetaleft(- z^{q} p + 1right), log{left (z^{q} p right )}:

\[\log^{n}{\left (z^{q} p \right )} \theta\left(- z^{q} p + 1\right) = \text{generated}\]
\[\log^{n}{\left (z^{q} p \right )} \theta\left(z^{q} p - 1\right) = \text{generated}\]

Functions involving operatorname{Shi}{left (z^{q} p right )}:

\[\begin{split}\operatorname{Shi}{\left (z^{q} p \right )} = \frac{\sqrt{\pi} p}{4} z^{q} {G_{1, 3}^{1, 1}\left(\begin{matrix} \frac{1}{2} & \\0 & - \frac{1}{2}, - \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q} e^{i \pi}} \right)}\end{split}\]

Functions involving operatorname{Si}{left (z^{q} p right )}:

\[\begin{split}\operatorname{Si}{\left (z^{q} p \right )} = \frac{\sqrt{\pi}}{2} {G_{1, 3}^{1, 1}\left(\begin{matrix} 1 & \\\frac{1}{2} & 0, 0 \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving I_{a}left(z^{q} pright):

\[\begin{split}I_{a}\left(z^{q} p\right) = \pi {G_{1, 3}^{1, 0}\left(\begin{matrix} & \frac{a}{2} + \frac{1}{2} \\\frac{a}{2} & - \frac{a}{2}, \frac{a}{2} + \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving J_{a}left(z^{q} pright):

\[\begin{split}J_{a}\left(z^{q} p\right) = {G_{0, 2}^{1, 0}\left(\begin{matrix} & \\\frac{a}{2} & - \frac{a}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving K_{a}left(z^{q} pright):

\[\begin{split}K_{a}\left(z^{q} p\right) = \frac{1}{2} {G_{0, 2}^{2, 0}\left(\begin{matrix} & \\\frac{a}{2}, - \frac{a}{2} & \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving Y_{a}left(z^{q} pright):

\[\begin{split}Y_{a}\left(z^{q} p\right) = {G_{1, 3}^{2, 0}\left(\begin{matrix} & - \frac{a}{2} - \frac{1}{2} \\\frac{a}{2}, - \frac{a}{2} & - \frac{a}{2} - \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving cos{left (z^{q} p right )}:

\[\begin{split}\cos{\left (z^{q} p \right )} = \sqrt{\pi} {G_{0, 2}^{1, 0}\left(\begin{matrix} & \\0 & \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving cosh{left (z^{q} p right )}:

\[\begin{split}\cosh{\left (z^{q} p \right )} = \pi^{\frac{3}{2}} {G_{1, 3}^{1, 0}\left(\begin{matrix} & \frac{1}{2} \\0 & \frac{1}{2}, \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving Eleft(z^{q} pright):

\[\begin{split}E\left(z^{q} p\right) = - \frac{1}{4} {G_{2, 2}^{1, 2}\left(\begin{matrix} \frac{1}{2}, \frac{3}{2} & \\0 & 0 \end{matrix} \middle| {- z^{q} p} \right)}\end{split}\]

Functions involving Kleft(z^{q} pright):

\[\begin{split}K\left(z^{q} p\right) = \frac{1}{2} {G_{2, 2}^{1, 2}\left(\begin{matrix} \frac{1}{2}, \frac{1}{2} & \\0 & 0 \end{matrix} \middle| {- z^{q} p} \right)}\end{split}\]

Functions involving operatorname{erf}{left (z^{q} p right )}:

\[\begin{split}\operatorname{erf}{\left (z^{q} p \right )} = \frac{1}{\sqrt{\pi}} {G_{1, 2}^{1, 1}\left(\begin{matrix} 1 & \\\frac{1}{2} & 0 \end{matrix} \middle| {z^{2 q} p^{2}} \right)}\end{split}\]

Functions involving operatorname{erfc}{left (z^{q} p right )}:

\[\begin{split}\operatorname{erfc}{\left (z^{q} p \right )} = \frac{1}{\sqrt{\pi}} {G_{1, 2}^{2, 0}\left(\begin{matrix} & 1 \\0, \frac{1}{2} & \end{matrix} \middle| {z^{2 q} p^{2}} \right)}\end{split}\]

Functions involving operatorname{erfi}{left (z^{q} p right )}:

\[\begin{split}\operatorname{erfi}{\left (z^{q} p \right )} = \frac{z^{q} p}{\sqrt{\pi}} {G_{1, 2}^{1, 1}\left(\begin{matrix} \frac{1}{2} & \\0 & - \frac{1}{2} \end{matrix} \middle| {- z^{2 q} p^{2}} \right)}\end{split}\]

Functions involving e^{z^{q} p e^{i pi}}:

\[\begin{split}e^{z^{q} p e^{i \pi}} = {G_{0, 1}^{1, 0}\left(\begin{matrix} & \\0 & \end{matrix} \middle| {z^{q} p} \right)}\end{split}\]

Functions involving operatorname{E}_{a}left(z^{q} pright):

\[\begin{split}\operatorname{E}_{a}\left(z^{q} p\right) = {G_{1, 2}^{2, 0}\left(\begin{matrix} & a \\a - 1, 0 & \end{matrix} \middle| {z^{q} p} \right)}\end{split}\]

Functions involving Cleft(z^{q} pright):

\[\begin{split}C\left(z^{q} p\right) = \frac{1}{2} {G_{1, 3}^{1, 1}\left(\begin{matrix} 1 & \\\frac{1}{4} & 0, \frac{3}{4} \end{matrix} \middle| {\frac{\pi^{2} p^{4}}{16} z^{4 q}} \right)}\end{split}\]

Functions involving Sleft(z^{q} pright):

\[\begin{split}S\left(z^{q} p\right) = \frac{1}{2} {G_{1, 3}^{1, 1}\left(\begin{matrix} 1 & \\\frac{3}{4} & 0, \frac{1}{4} \end{matrix} \middle| {\frac{\pi^{2} p^{4}}{16} z^{4 q}} \right)}\end{split}\]

Functions involving log{left (z^{q} p right )}:

\[\log^{n}{\left (z^{q} p \right )} = \text{generated}\]
\[\begin{split}\log{\left (z^{q} p + a \right )} = {G_{1, 1}^{1, 0}\left(\begin{matrix} & 1 \\0 & \end{matrix} \middle| {z} \right)} \log{\left (a \right )} + {G_{1, 1}^{0, 1}\left(\begin{matrix} 1 & \\ & 0 \end{matrix} \middle| {z} \right)} \log{\left (a \right )} + {G_{2, 2}^{1, 2}\left(\begin{matrix} 1, 1 & \\1 & 0 \end{matrix} \middle| {\frac{z^{q} p}{a}} \right)}\end{split}\]
\[\begin{split}\log{\left (\left|{z^{q} p - a}\right| \right )} = {G_{1, 1}^{1, 0}\left(\begin{matrix} & 1 \\0 & \end{matrix} \middle| {z} \right)} \log{\left (\left|{a}\right| \right )} + {G_{1, 1}^{0, 1}\left(\begin{matrix} 1 & \\ & 0 \end{matrix} \middle| {z} \right)} \log{\left (\left|{a}\right| \right )} + \pi {G_{3, 3}^{1, 2}\left(\begin{matrix} 1, 1 & \frac{1}{2} \\1 & 0, \frac{1}{2} \end{matrix} \middle| {\frac{z^{q} p}{a}} \right)}\end{split}\]

Functions involving sin{left (z^{q} p right )}:

\[\begin{split}\sin{\left (z^{q} p \right )} = \sqrt{\pi} {G_{0, 2}^{1, 0}\left(\begin{matrix} & \\\frac{1}{2} & 0 \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving operatorname{sinc}{left (z^{q} p right )}:

\[\begin{split}\operatorname{sinc}{\left (z^{q} p \right )} = \frac{\sqrt{\pi}}{2} {G_{0, 2}^{1, 0}\left(\begin{matrix} & \\0 & - \frac{1}{2} \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

Functions involving sinh{left (z^{q} p right )}:

\[\begin{split}\sinh{\left (z^{q} p \right )} = \pi^{\frac{3}{2}} {G_{1, 3}^{1, 0}\left(\begin{matrix} & 1 \\\frac{1}{2} & 1, 0 \end{matrix} \middle| {\frac{p^{2}}{4} z^{2 q}} \right)}\end{split}\]

modelparameters.sympy.integrals.prde module

modelparameters.sympy.integrals.quadrature module

modelparameters.sympy.integrals.quadrature.gauss_chebyshev_t(n, n_digits)[source]

Computes the Gauss-Chebyshev quadrature [1]_ points and weights of the first kind.

The Gauss-Chebyshev quadrature of the first kind approximates the integral:

\[\int_{-1}^{1} \frac{1}{\sqrt{1-x^2}} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of T_n and the weights w_i are given by:

\[w_i = \frac{\pi}{n}\]
Parameters:
  • n (the order of quadrature) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .. import S
>>> from .quadrature import gauss_chebyshev_t
>>> x, w = gauss_chebyshev_t(3, 5)
>>> x
[0.86602, 0, -0.86602]
>>> w
[1.0472, 1.0472, 1.0472]
>>> x, w = gauss_chebyshev_t(6, 5)
>>> x
[0.96593, 0.70711, 0.25882, -0.25882, -0.70711, -0.96593]
>>> w
[0.5236, 0.5236, 0.5236, 0.5236, 0.5236, 0.5236]

References

modelparameters.sympy.integrals.quadrature.gauss_chebyshev_u(n, n_digits)[source]

Computes the Gauss-Chebyshev quadrature [1]_ points and weights of the second kind.

The Gauss-Chebyshev quadrature of the second kind approximates the integral:

\[\int_{-1}^{1} \sqrt{1-x^2} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of U_n and the weights w_i are given by:

\[w_i = \frac{\pi}{n+1} \sin^2 \left(\frac{i}{n+1}\pi\right)\]
Parameters:
  • n (the order of quadrature) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .. import S
>>> from .quadrature import gauss_chebyshev_u
>>> x, w = gauss_chebyshev_u(3, 5)
>>> x
[0.70711, 0, -0.70711]
>>> w
[0.3927, 0.7854, 0.3927]
>>> x, w = gauss_chebyshev_u(6, 5)
>>> x
[0.90097, 0.62349, 0.22252, -0.22252, -0.62349, -0.90097]
>>> w
[0.084489, 0.27433, 0.42658, 0.42658, 0.27433, 0.084489]

References

modelparameters.sympy.integrals.quadrature.gauss_gen_laguerre(n, alpha, n_digits)[source]

Computes the generalized Gauss-Laguerre quadrature [1]_ points and weights.

The generalized Gauss-Laguerre quadrature approximates the integral:

\[\int_{0}^\infty x^{\alpha} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of L^{alpha}_n and the weights w_i are given by:

\[w_i = \frac{\Gamma(\alpha+n)} {n \Gamma(n) L^{\alpha}_{n-1}(x_i) L^{\alpha+1}_{n-1}(x_i)}\]
Parameters:
  • n (the order of quadrature) –

  • alpha (the exponent of the singularity, alpha > -1) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .. import S
>>> from .quadrature import gauss_gen_laguerre
>>> x, w = gauss_gen_laguerre(3, -S.Half, 5)
>>> x
[0.19016, 1.7845, 5.5253]
>>> w
[1.4493, 0.31413, 0.00906]
>>> x, w = gauss_gen_laguerre(4, 3*S.Half, 5)
>>> x
[0.97851, 2.9904, 6.3193, 11.712]
>>> w
[0.53087, 0.67721, 0.11895, 0.0023152]

References

modelparameters.sympy.integrals.quadrature.gauss_hermite(n, n_digits)[source]

Computes the Gauss-Hermite quadrature [1]_ points and weights.

The Gauss-Hermite quadrature approximates the integral:

\[\int_{-\infty}^{\infty} e^{-x^2} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of H_n and the weights w_i are given by:

\[w_i = \frac{2^{n-1} n! \sqrt{\pi}}{n^2 \left(H_{n-1}(x_i)\right)^2}\]
Parameters:
  • n (the order of quadrature) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .quadrature import gauss_hermite
>>> x, w = gauss_hermite(3, 5)
>>> x
[-1.2247, 0, 1.2247]
>>> w
[0.29541, 1.1816, 0.29541]
>>> x, w = gauss_hermite(6, 5)
>>> x
[-2.3506, -1.3358, -0.43608, 0.43608, 1.3358, 2.3506]
>>> w
[0.00453, 0.15707, 0.72463, 0.72463, 0.15707, 0.00453]

References

modelparameters.sympy.integrals.quadrature.gauss_jacobi(n, alpha, beta, n_digits)[source]

Computes the Gauss-Jacobi quadrature [1]_ points and weights.

The Gauss-Jacobi quadrature of the first kind approximates the integral:

\[\int_{-1}^1 (1-x)^\alpha (1+x)^\beta f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of P^{(alpha,beta)}_n and the weights w_i are given by:

\[w_i = -\frac{2n+\alpha+\beta+2}{n+\alpha+\beta+1} \frac{\Gamma(n+\alpha+1)\Gamma(n+\beta+1)} {\Gamma(n+\alpha+\beta+1)(n+1)!} \frac{2^{\alpha+\beta}}{P'_n(x_i) P^{(\alpha,\beta)}_{n+1}(x_i)}\]
Parameters:
  • n (the order of quadrature) –

  • alpha (the first parameter of the Jacobi Polynomial, alpha > -1) –

  • beta (the second parameter of the Jacobi Polynomial, beta > -1) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .. import S
>>> from .quadrature import gauss_jacobi
>>> x, w = gauss_jacobi(3, S.Half, -S.Half, 5)
>>> x
[-0.90097, -0.22252, 0.62349]
>>> w
[1.7063, 1.0973, 0.33795]
>>> x, w = gauss_jacobi(6, 1, 1, 5)
>>> x
[-0.87174, -0.5917, -0.2093, 0.2093, 0.5917, 0.87174]
>>> w
[0.050584, 0.22169, 0.39439, 0.39439, 0.22169, 0.050584]

References

modelparameters.sympy.integrals.quadrature.gauss_laguerre(n, n_digits)[source]

Computes the Gauss-Laguerre quadrature [1]_ points and weights.

The Gauss-Laguerre quadrature approximates the integral:

\[\int_0^{\infty} e^{-x} f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of L_n and the weights w_i are given by:

\[w_i = \frac{x_i}{(n+1)^2 \left(L_{n+1}(x_i)\right)^2}\]
Parameters:
  • n (the order of quadrature) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .quadrature import gauss_laguerre
>>> x, w = gauss_laguerre(3, 5)
>>> x
[0.41577, 2.2943, 6.2899]
>>> w
[0.71109, 0.27852, 0.010389]
>>> x, w = gauss_laguerre(6, 5)
>>> x
[0.22285, 1.1889, 2.9927, 5.7751, 9.8375, 15.983]
>>> w
[0.45896, 0.417, 0.11337, 0.010399, 0.00026102, 8.9855e-7]

References

modelparameters.sympy.integrals.quadrature.gauss_legendre(n, n_digits)[source]

Computes the Gauss-Legendre quadrature [1]_ points and weights.

The Gauss-Legendre quadrature approximates the integral:

\[\int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of P_n and the weights w_i are given by:

\[w_i = \frac{2}{\left(1-x_i^2\right) \left(P'_n(x_i)\right)^2}\]
Parameters:
  • n (the order of quadrature) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .quadrature import gauss_legendre
>>> x, w = gauss_legendre(3, 5)
>>> x
[-0.7746, 0, 0.7746]
>>> w
[0.55556, 0.88889, 0.55556]
>>> x, w = gauss_legendre(4, 5)
>>> x
[-0.86114, -0.33998, 0.33998, 0.86114]
>>> w
[0.34786, 0.65215, 0.65215, 0.34786]

References

modelparameters.sympy.integrals.quadrature.gauss_lobatto(n, n_digits)[source]

Computes the Gauss-Lobatto quadrature [1]_ points and weights.

The Gauss-Lobatto quadrature approximates the integral:

\[\int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^n w_i f(x_i)\]

The nodes x_i of an order n quadrature rule are the roots of P’_(n-1) and the weights w_i are given by:

\[\begin{split}&w_i = \frac{2}{n(n-1) \left[P_{n-1}(x_i)\right]^2},\quad x\neq\pm 1\\ &w_i = \frac{2}{n(n-1)},\quad x=\pm 1\end{split}\]
Parameters:
  • n (the order of quadrature) –

  • n_digits (number of significant digits of the points and weights to return) –

Returns:

(x, w) – The points x_i and weights w_i are returned as (x, w) tuple of lists.

Return type:

the x and w are lists of points and weights as Floats.

Examples

>>> from .quadrature import gauss_lobatto
>>> x, w = gauss_lobatto(3, 5)
>>> x
[-1, 0, 1]
>>> w
[0.33333, 1.3333, 0.33333]
>>> x, w = gauss_lobatto(4, 5)
>>> x
[-1, -0.44721, 0.44721, 1]
>>> w
[0.16667, 0.83333, 0.83333, 0.16667]

References

modelparameters.sympy.integrals.rationaltools module

This module implements tools for integrating rational functions.

modelparameters.sympy.integrals.rationaltools.log_to_atan(f, g)[source]

Convert complex logarithms to real arctangents.

Given a real field K and polynomials f and g in K[x], with g != 0, returns a sum h of arctangents of polynomials in K[x], such that:

dh d f + I g – = – I log( ——- ) dx dx f - I g

Examples

>>> from .rationaltools import log_to_atan
>>> from ..abc import x
>>> from .. import Poly, sqrt, S
>>> log_to_atan(Poly(x, x, domain='ZZ'), Poly(1, x, domain='ZZ'))
2*atan(x)
>>> log_to_atan(Poly(x + S(1)/2, x, domain='QQ'),
... Poly(sqrt(3)/2, x, domain='EX'))
2*atan(2*sqrt(3)*x/3 + sqrt(3)/3)

See also

log_to_real

modelparameters.sympy.integrals.rationaltools.log_to_real(h, q, x, t)[source]

Convert complex logarithms to real functions.

Given real field K and polynomials h in K[t,x] and q in K[t], returns real function f such that:

___

df d ` – = – ) a log(h(a, x)) dx dx /__,

a | q(a) = 0

Examples

>>> from .rationaltools import log_to_real
>>> from ..abc import x, y
>>> from .. import Poly, sqrt, S
>>> log_to_real(Poly(x + 3*y/2 + S(1)/2, x, domain='QQ[y]'),
... Poly(3*y**2 + 1, y, domain='ZZ'), x, y)
2*sqrt(3)*atan(2*sqrt(3)*x/3 + sqrt(3)/3)/3
>>> log_to_real(Poly(x**2 - 1, x, domain='ZZ'),
... Poly(-2*y + 1, y, domain='ZZ'), x, y)
log(x**2 - 1)/2

See also

log_to_atan

modelparameters.sympy.integrals.rationaltools.ratint(f, x, **flags)[source]

Performs indefinite integration of rational functions.

Given a field \(K\) and a rational function \(f = p/q\), where \(p\) and \(q\) are polynomials in \(K[x]\), returns a function \(g\) such that \(f = g'\).

>>> from .rationaltools import ratint
>>> from ..abc import x
>>> ratint(36/(x**5 - 2*x**4 - 2*x**3 + 4*x**2 + x - 2), x)
(12*x + 6)/(x**2 - 1) + 4*log(x - 2) - 4*log(x + 1)

References

[Bro05]

M. Bronstein, Symbolic Integration I: Transcendental Functions, Second Edition, Springer-Verlag, 2005, pp. 35-70

See also

sympy.integrals.integrals.Integral.doit, ratint_logpart, ratint_ratpart

modelparameters.sympy.integrals.rationaltools.ratint_logpart(f, g, x, t=None)[source]

Lazard-Rioboo-Trager algorithm.

Given a field K and polynomials f and g in K[x], such that f and g are coprime, deg(f) < deg(g) and g is square-free, returns a list of tuples (s_i, q_i) of polynomials, for i = 1..n, such that s_i in K[t, x] and q_i in K[t], and:

___ ___

d f d ` ` – - = – ) ) a log(s_i(a, x)) dx g dx /__, /__,

i=1..n a | q_i(a) = 0

Examples

>>> from .rationaltools import ratint_logpart
>>> from ..abc import x
>>> from .. import Poly
>>> ratint_logpart(Poly(1, x, domain='ZZ'),
... Poly(x**2 + x + 1, x, domain='ZZ'), x)
[(Poly(x + 3*_t/2 + 1/2, x, domain='QQ[_t]'),
...Poly(3*_t**2 + 1, _t, domain='ZZ'))]
>>> ratint_logpart(Poly(12, x, domain='ZZ'),
... Poly(x**2 - x - 2, x, domain='ZZ'), x)
[(Poly(x - 3*_t/8 - 1/2, x, domain='QQ[_t]'),
...Poly(-_t**2 + 16, _t, domain='ZZ'))]
modelparameters.sympy.integrals.rationaltools.ratint_ratpart(f, g, x)[source]

Horowitz-Ostrogradsky algorithm.

Given a field K and polynomials f and g in K[x], such that f and g are coprime and deg(f) < deg(g), returns fractions A and B in K(x), such that f/g = A’ + B and B has square-free denominator.

Examples

>>> from .rationaltools import ratint_ratpart
>>> from ..abc import x, y
>>> from .. import Poly
>>> ratint_ratpart(Poly(1, x, domain='ZZ'),
... Poly(x + 1, x, domain='ZZ'), x)
(0, 1/(x + 1))
>>> ratint_ratpart(Poly(1, x, domain='EX'),
... Poly(x**2 + y**2, x, domain='EX'), x)
(0, 1/(x**2 + y**2))
>>> ratint_ratpart(Poly(36, x, domain='ZZ'),
... Poly(x**5 - 2*x**4 - 2*x**3 + 4*x**2 + x - 2, x, domain='ZZ'), x)
((12*x + 6)/(x**2 - 1), 12/(x**2 - x - 2))

modelparameters.sympy.integrals.rde module

modelparameters.sympy.integrals.risch module

modelparameters.sympy.integrals.singularityfunctions module

modelparameters.sympy.integrals.singularityfunctions.singularityintegrate(f, x)[source]

This function handles the indefinite integrations of Singularity functions. The integrate function calls this function internally whenever an instance of SingularityFunction is passed as argument.

The idea for integration is the following:

  • If we are dealing with a SingularityFunction expression, i.e. SingularityFunction(x, a, n), we just return SingularityFunction(x, a, n + 1)/(n + 1) if n >= 0 and SingularityFunction(x, a, n + 1) if n < 0.

  • If the node is a multiplication or power node having a SingularityFunction term we rewrite the whole expression in terms of Heaviside and DiracDelta and then integrate the output. Lastly, we rewrite the output of integration back in terms of SingularityFunction.

  • If none of the above case arises, we return None.

Examples

>>> from .singularityfunctions import singularityintegrate
>>> from .. import SingularityFunction, symbols, Function
>>> x, a, n, y = symbols('x a n y')
>>> f = Function('f')
>>> singularityintegrate(SingularityFunction(x, a, 3), x)
SingularityFunction(x, a, 4)/4
>>> singularityintegrate(5*SingularityFunction(x, 5, -2), x)
5*SingularityFunction(x, 5, -1)
>>> singularityintegrate(6*SingularityFunction(x, 5, -1), x)
6*SingularityFunction(x, 5, 0)
>>> singularityintegrate(x*SingularityFunction(x, 0, -1), x)
0
>>> singularityintegrate(SingularityFunction(x, 1, -1) * f(x), x)
f(1)*SingularityFunction(x, 1, 0)

modelparameters.sympy.integrals.transforms module

Integral Transforms

class modelparameters.sympy.integrals.transforms.CosineTransform(*args)[source]

Bases: SineCosineTypeTransform

Class representing unevaluated cosine transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute cosine transforms, see the cosine_transform() docstring.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.FourierTransform(*args)[source]

Bases: FourierTypeTransform

Class representing unevaluated Fourier transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute Fourier transforms, see the fourier_transform() docstring.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.FourierTypeTransform(*args)[source]

Bases: IntegralTransform

Base class for Fourier transforms.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.HankelTransform(*args)[source]

Bases: HankelTypeTransform

Class representing unevaluated Hankel transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute Hankel transforms, see the hankel_transform() docstring.

default_assumptions = {}
class modelparameters.sympy.integrals.transforms.HankelTypeTransform(*args)[source]

Bases: IntegralTransform

Base class for Hankel transforms.

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

Try to evaluate the transform in closed form.

This general function handles linearity, but apart from that leaves pretty much everything to _compute_transform.

Standard hints are the following:

  • simplify: whether or not to simplify the result

  • noconds: if True, don’t return convergence conditions

  • needeval: if True, raise IntegralTransformError instead of

    returning IntegralTransform objects

The default values of these hints depend on the concrete transform, usually the default is (simplify, noconds, needeval) = (True, False, False).

class modelparameters.sympy.integrals.transforms.IntegralTransform(*args)[source]

Bases: Function

Base class for integral transforms.

This class represents unevaluated transforms.

To implement a concrete transform, derive from this class and implement the _compute_transform(f, x, s, **hints) and _as_integral(f, x, s) functions. If the transform cannot be computed, raise IntegralTransformError.

Also set cls._name.

Implement self._collapse_extra if your function returns more than just a number and possibly a convergence condition.

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

Try to evaluate the transform in closed form.

This general function handles linearity, but apart from that leaves pretty much everything to _compute_transform.

Standard hints are the following:

  • simplify: whether or not to simplify the result

  • noconds: if True, don’t return convergence conditions

  • needeval: if True, raise IntegralTransformError instead of

    returning IntegralTransform objects

The default values of these hints depend on the concrete transform, usually the default is (simplify, noconds, needeval) = (True, False, False).

property free_symbols

This method returns the symbols that will exist when the transform is evaluated.

property function

The function to be transformed.

property function_variable

The dependent variable of the function to be transformed.

property transform_variable

The independent transform variable.

exception modelparameters.sympy.integrals.transforms.IntegralTransformError(transform, function, msg)[source]

Bases: NotImplementedError

Exception raised in relation to problems computing transforms.

This class is mostly used internally; if integrals cannot be computed objects representing unevaluated transforms are usually returned.

The hint needeval=True can be used to disable returning transform objects, and instead raise this exception if an integral cannot be computed.

class modelparameters.sympy.integrals.transforms.InverseCosineTransform(*args)[source]

Bases: SineCosineTypeTransform

Class representing unevaluated inverse cosine transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute inverse cosine transforms, see the inverse_cosine_transform() docstring.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.InverseFourierTransform(*args)[source]

Bases: FourierTypeTransform

Class representing unevaluated inverse Fourier transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute inverse Fourier transforms, see the inverse_fourier_transform() docstring.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.InverseHankelTransform(*args)[source]

Bases: HankelTypeTransform

Class representing unevaluated inverse Hankel transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute inverse Hankel transforms, see the inverse_hankel_transform() docstring.

default_assumptions = {}
class modelparameters.sympy.integrals.transforms.InverseLaplaceTransform(*args)[source]

Bases: IntegralTransform

Class representing unevaluated inverse Laplace transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute inverse Laplace transforms, see the inverse_laplace_transform() docstring.

default_assumptions = {}
property fundamental_plane
class modelparameters.sympy.integrals.transforms.InverseMellinTransform(*args)[source]

Bases: IntegralTransform

Class representing unevaluated inverse Mellin transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute inverse Mellin transforms, see the inverse_mellin_transform() docstring.

default_assumptions = {}
property fundamental_strip
class modelparameters.sympy.integrals.transforms.InverseSineTransform(*args)[source]

Bases: SineCosineTypeTransform

Class representing unevaluated inverse sine transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute inverse sine transforms, see the inverse_sine_transform() docstring.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.LaplaceTransform(*args)[source]

Bases: IntegralTransform

Class representing unevaluated Laplace transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute Laplace transforms, see the laplace_transform() docstring.

default_assumptions = {}
class modelparameters.sympy.integrals.transforms.MellinTransform(*args)[source]

Bases: IntegralTransform

Class representing unevaluated Mellin transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute Mellin transforms, see the mellin_transform() docstring.

default_assumptions = {}
exception modelparameters.sympy.integrals.transforms.MellinTransformStripError[source]

Bases: ValueError

Exception raised by _rewrite_gamma. Mainly for internal use.

class modelparameters.sympy.integrals.transforms.SineCosineTypeTransform(*args)[source]

Bases: IntegralTransform

Base class for sine and cosine transforms. Specify cls._kern.

a()[source]
b()[source]
default_assumptions = {}
class modelparameters.sympy.integrals.transforms.SineTransform(*args)[source]

Bases: SineCosineTypeTransform

Class representing unevaluated sine transforms.

For usage of this class, see the IntegralTransform docstring.

For how to compute sine transforms, see the sine_transform() docstring.

a()[source]
b()[source]
default_assumptions = {}
modelparameters.sympy.integrals.transforms.cosine_transform(f, x, k, **hints)[source]

Compute the unitary, ordinary-frequency cosine transform of f, defined as

\[F(k) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty f(x) \cos(2\pi x k) \mathrm{d} x.\]

If the transform cannot be computed in closed form, this function returns an unevaluated CosineTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import cosine_transform, exp, sqrt, cos
>>> from ..abc import x, k, a
>>> cosine_transform(exp(-a*x), x, k)
sqrt(2)*a/(sqrt(pi)*(a**2 + k**2))
>>> cosine_transform(exp(-a*sqrt(x))*cos(a*sqrt(x)), x, k)
a*exp(-a**2/(2*k))/(2*k**(3/2))
modelparameters.sympy.integrals.transforms.fourier_transform(f, x, k, **hints)[source]

Compute the unitary, ordinary-frequency Fourier transform of f, defined as

\[F(k) = \int_{-\infty}^\infty f(x) e^{-2\pi i x k} \mathrm{d} x.\]

If the transform cannot be computed in closed form, this function returns an unevaluated FourierTransform object.

For other Fourier transform conventions, see the function sympy.integrals.transforms._fourier_transform().

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import fourier_transform, exp
>>> from ..abc import x, k
>>> fourier_transform(exp(-x**2), x, k)
sqrt(pi)*exp(-pi**2*k**2)
>>> fourier_transform(exp(-x**2), x, k, noconds=False)
(sqrt(pi)*exp(-pi**2*k**2), True)
modelparameters.sympy.integrals.transforms.hankel_transform(f, r, k, nu, **hints)[source]

Compute the Hankel transform of f, defined as

\[F_\nu(k) = \int_{0}^\infty f(r) J_\nu(k r) r \mathrm{d} r.\]

If the transform cannot be computed in closed form, this function returns an unevaluated HankelTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import hankel_transform, inverse_hankel_transform
>>> from .. import gamma, exp, sinh, cosh
>>> from ..abc import r, k, m, nu, a
>>> ht = hankel_transform(1/r**m, r, k, nu)
>>> ht
2*2**(-m)*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/gamma(m/2 + nu/2)
>>> inverse_hankel_transform(ht, k, r, nu)
r**(-m)
>>> ht = hankel_transform(exp(-a*r), r, k, 0)
>>> ht
a/(k**3*(a**2/k**2 + 1)**(3/2))
>>> inverse_hankel_transform(ht, k, r, 0)
exp(-a*r)
modelparameters.sympy.integrals.transforms.inverse_cosine_transform(F, k, x, **hints)[source]

Compute the unitary, ordinary-frequency inverse cosine transform of F, defined as

\[f(x) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty F(k) \cos(2\pi x k) \mathrm{d} k.\]

If the transform cannot be computed in closed form, this function returns an unevaluated InverseCosineTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import inverse_cosine_transform, exp, sqrt, pi
>>> from ..abc import x, k, a
>>> inverse_cosine_transform(sqrt(2)*a/(sqrt(pi)*(a**2 + k**2)), k, x)
exp(-a*x)
>>> inverse_cosine_transform(1/sqrt(k), k, x)
1/sqrt(x)
modelparameters.sympy.integrals.transforms.inverse_fourier_transform(F, k, x, **hints)[source]

Compute the unitary, ordinary-frequency inverse Fourier transform of F, defined as

\[f(x) = \int_{-\infty}^\infty F(k) e^{2\pi i x k} \mathrm{d} k.\]

If the transform cannot be computed in closed form, this function returns an unevaluated InverseFourierTransform object.

For other Fourier transform conventions, see the function sympy.integrals.transforms._fourier_transform().

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import inverse_fourier_transform, exp, sqrt, pi
>>> from ..abc import x, k
>>> inverse_fourier_transform(sqrt(pi)*exp(-(pi*k)**2), k, x)
exp(-x**2)
>>> inverse_fourier_transform(sqrt(pi)*exp(-(pi*k)**2), k, x, noconds=False)
(exp(-x**2), True)
modelparameters.sympy.integrals.transforms.inverse_hankel_transform(F, k, r, nu, **hints)[source]

Compute the inverse Hankel transform of F defined as

\[f(r) = \int_{0}^\infty F_\nu(k) J_\nu(k r) k \mathrm{d} k.\]

If the transform cannot be computed in closed form, this function returns an unevaluated InverseHankelTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import hankel_transform, inverse_hankel_transform, gamma
>>> from .. import gamma, exp, sinh, cosh
>>> from ..abc import r, k, m, nu, a
>>> ht = hankel_transform(1/r**m, r, k, nu)
>>> ht
2*2**(-m)*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/gamma(m/2 + nu/2)
>>> inverse_hankel_transform(ht, k, r, nu)
r**(-m)
>>> ht = hankel_transform(exp(-a*r), r, k, 0)
>>> ht
a/(k**3*(a**2/k**2 + 1)**(3/2))
>>> inverse_hankel_transform(ht, k, r, 0)
exp(-a*r)
modelparameters.sympy.integrals.transforms.inverse_laplace_transform(F, s, t, plane=None, **hints)[source]

Compute the inverse Laplace transform of F(s), defined as

\[f(t) = \int_{c-i\infty}^{c+i\infty} e^{st} F(s) \mathrm{d}s,\]

for c so large that F(s) has no singularites in the half-plane operatorname{Re}(s) > c-epsilon.

The plane can be specified by argument plane, but will be inferred if passed as None.

Under certain regularity conditions, this recovers f(t) from its Laplace Transform F(s), for non-negative t, and vice versa.

If the integral cannot be computed in closed form, this function returns an unevaluated InverseLaplaceTransform object.

Note that this function will always assume t to be real, regardless of the sympy assumption on t.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit().

>>> from .transforms import inverse_laplace_transform
>>> from .. import exp, Symbol
>>> from ..abc import s, t
>>> a = Symbol('a', positive=True)
>>> inverse_laplace_transform(exp(-a*s)/s, s, t)
Heaviside(-a + t)
modelparameters.sympy.integrals.transforms.inverse_mellin_transform(F, s, x, strip, **hints)[source]

Compute the inverse Mellin transform of F(s) over the fundamental strip given by strip=(a, b).

This can be defined as

\[f(x) = \int_{c - i\infty}^{c + i\infty} x^{-s} F(s) \mathrm{d}s,\]

for any c in the fundamental strip. Under certain regularity conditions on F and/or f, this recovers f from its Mellin transform F (and vice versa), for positive real x.

One of a or b may be passed as None; a suitable c will be inferred.

If the integral cannot be computed in closed form, this function returns an unevaluated InverseMellinTransform object.

Note that this function will assume x to be positive and real, regardless of the sympy assumptions!

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit().

>>> from .transforms import inverse_mellin_transform
>>> from .. import oo, gamma
>>> from ..abc import x, s
>>> inverse_mellin_transform(gamma(s), s, x, (0, oo))
exp(-x)

The fundamental strip matters:

>>> f = 1/(s**2 - 1)
>>> inverse_mellin_transform(f, s, x, (-oo, -1))
(x/2 - 1/(2*x))*Heaviside(x - 1)
>>> inverse_mellin_transform(f, s, x, (-1, 1))
-x*Heaviside(-x + 1)/2 - Heaviside(x - 1)/(2*x)
>>> inverse_mellin_transform(f, s, x, (1, oo))
(-x/2 + 1/(2*x))*Heaviside(-x + 1)
modelparameters.sympy.integrals.transforms.inverse_sine_transform(F, k, x, **hints)[source]

Compute the unitary, ordinary-frequency inverse sine transform of F, defined as

\[f(x) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty F(k) \sin(2\pi x k) \mathrm{d} k.\]

If the transform cannot be computed in closed form, this function returns an unevaluated InverseSineTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import inverse_sine_transform, exp, sqrt, gamma, pi
>>> from ..abc import x, k, a
>>> inverse_sine_transform(2**((1-2*a)/2)*k**(a - 1)*
...     gamma(-a/2 + 1)/gamma((a+1)/2), k, x)
x**(-a)
>>> inverse_sine_transform(sqrt(2)*k*exp(-k**2/(4*a))/(4*sqrt(a)**3), k, x)
x*exp(-a*x**2)
modelparameters.sympy.integrals.transforms.laplace_transform(f, t, s, **hints)[source]

Compute the Laplace Transform F(s) of f(t),

\[F(s) = \int_0^\infty e^{-st} f(t) \mathrm{d}t.\]

For all “sensible” functions, this converges absolutely in a half plane a < operatorname{Re}(s).

This function returns (F, a, cond) where F is the Laplace transform of f, operatorname{Re}(s) > a is the half-plane of convergence, and cond are auxiliary convergence conditions.

If the integral cannot be computed in closed form, this function returns an unevaluated LaplaceTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). If noconds=True, only F will be returned (i.e. not cond, and also not the plane a).

>>> from ..integrals import laplace_transform
>>> from ..abc import t, s, a
>>> laplace_transform(t**a, t, s)
(s**(-a)*gamma(a + 1)/s, 0, -re(a) < 1)
modelparameters.sympy.integrals.transforms.mellin_transform(f, x, s, **hints)[source]

Compute the Mellin transform F(s) of f(x),

\[F(s) = \int_0^\infty x^{s-1} f(x) \mathrm{d}x.\]
For all “sensible” functions, this converges absolutely in a strip

a < operatorname{Re}(s) < b.

The Mellin transform is related via change of variables to the Fourier transform, and also to the (bilateral) Laplace transform.

This function returns (F, (a, b), cond) where F is the Mellin transform of f, (a, b) is the fundamental strip (as above), and cond are auxiliary convergence conditions.

If the integral cannot be computed in closed form, this function returns an unevaluated MellinTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). If noconds=False, then only F will be returned (i.e. not cond, and also not the strip (a, b)).

>>> from .transforms import mellin_transform
>>> from .. import exp
>>> from ..abc import x, s
>>> mellin_transform(exp(-x), x, s)
(gamma(s), (0, oo), True)
modelparameters.sympy.integrals.transforms.sine_transform(f, x, k, **hints)[source]

Compute the unitary, ordinary-frequency sine transform of f, defined as

\[F(k) = \sqrt{\frac{2}{\pi}} \int_{0}^\infty f(x) \sin(2\pi x k) \mathrm{d} x.\]

If the transform cannot be computed in closed form, this function returns an unevaluated SineTransform object.

For a description of possible hints, refer to the docstring of sympy.integrals.transforms.IntegralTransform.doit(). Note that for this transform, by default noconds=True.

>>> from .. import sine_transform, exp
>>> from ..abc import x, k, a
>>> sine_transform(x*exp(-a*x**2), x, k)
sqrt(2)*k*exp(-k**2/(4*a))/(4*a**(3/2))
>>> sine_transform(x**(-a), x, k)
2**(-a + 1/2)*k**(a - 1)*gamma(-a/2 + 1)/gamma(a/2 + 1/2)

modelparameters.sympy.integrals.trigonometry module

modelparameters.sympy.integrals.trigonometry.trigintegrate(f, x, conds='piecewise')[source]

Integrate f = Mul(trig) over x

>>> from .. import Symbol, sin, cos, tan, sec, csc, cot
>>> from .trigonometry import trigintegrate
>>> from ..abc import x
>>> trigintegrate(sin(x)*cos(x), x)
sin(x)**2/2
>>> trigintegrate(sin(x)**2, x)
x/2 - sin(x)*cos(x)/2
>>> trigintegrate(tan(x)*sec(x), x)
1/cos(x)
>>> trigintegrate(sin(x)*tan(x), x)
-log(sin(x) - 1)/2 + log(sin(x) + 1)/2 - sin(x)

http://en.wikibooks.org/wiki/Calculus/Integration_techniques

See also

sympy.integrals.integrals.Integral.doit, sympy.integrals.integrals.Integral

Module contents

Integration functions that integrates a sympy expression.

Examples

>>> from .. import integrate, sin
>>> from ..abc import x
>>> integrate(1/x,x)
log(x)
>>> integrate(sin(x),x)
-cos(x)