SymPy – 16 – calcolo infinitesimale – 2

Continuo da qui, copio qui.

To compute an integral, use the integrate function. There are two kinds of integrals, definite and indefinite. To compute an indefinite integral, that is, an antiderivative, or primitive, just pass the variable after the expression.

Note that SymPy does not include the constant of integration. If you want it, you can add one yourself, or rephrase your problem as a differential equation and use dsolve to solve it, which does add the constant (see Solving Differential Equations [prossimamente]).

To compute a definite integral, pass the argument (integration_variable, lower_limit, upper_limit). For example, to compute

we would do

Quick Tip: in SymPy is oo (that’s the lowercase letter “oh” twice). This is because oo looks like , and is easy to type.

As with indefinite integrals, you can pass multiple limit tuples to perform a multiple integral. For example, to compute


If integrate is unable to compute an integral, it returns an unevaluated Integral object.

As with Derivative, you can create an unevaluated integral using Integral. To later evaluate this integral, call doit.

integrate uses powerful algorithms that are always improving to compute both definite and indefinite integrals, including heuristic pattern matching type algorithms, a partial implementation of the Risch algorithm, and an algorithm using Meijer G-functions that is useful for computing integrals in terms of special functions, especially definite integrals. Here is a sampling of some of the power of integrate.

This last example returned a Piecewise expression because the integral does not converge unless R(y)>1.

Impressionante vero? peccato aver già dato Analisi (I e II (inizio anni ’70)) 😜


Posta un commento o usa questo indirizzo per il trackback.



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di

Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.

%d blogger hanno fatto clic su Mi Piace per questo: