integrate(function, x)
integrates expression function
with respect
to the symbolic variable x
. Jasymca uses the following strategy:
>> syms x >> integrate(x^2+x-3,x) ans = 0.33333*x^3+0.5*x^2-3*x >> integrate(sin(x),x) ans = -cos(x)
function
is rational (i.e. quotient of
two polynomials, whose coefficients do not depend
on x
)) we use the standard approach:
Separate a polynomial part, then separate
a square free part using Horowitz' [11] method, and finally
integrate the rest using partial fractions.
The final terms are collected to avoid
complex expressions.
>> syms x >> y=(x^3+2*x^2-x+1)/((x+i)*(x-i)*(x+3)) y = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3) >> integrate(y,x) ans = -1/4*log(x^2+1)+(-1/2*log(x+3)+(-1/2*atan(x)+x)) >> diff(ans,x) % control ans = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3)
>> syms x >> integrate(x*exp(-2*x^2),x) ans = -0.25*exp(-2*x^2) >> integrate(exp(x)/(3+exp(x)),x) ans = log(exp(x)+3)
>> syms x >> integrate(3*sin(2*x-4),x) ans = -1.5*cos(2*x-4)
>> syms x >> integrate(x^3*exp(-2*x),x) ans = (-0.5*x^3-0.75*x^2-0.75*x-0.375)*exp(-2*x) >> integrate(x^2*log(x),x) ans = 0.33333*x^3*log(x)-0.11111*x^3
>> syms x >> integrate(sin(x)*cos(3*x)^2,x) ans = -3.5714E-2*cos(7*x)+(5.0E-2*cos(5*x)-0.5*cos(x)) >> integrate(1/(sin(3*x)+1),x) ans = -2/3*cos(3/2*x)/(sin(3/2*x)+cos(3/2*x))
>> syms x >> integrate(sqrt(x^2-1),x) ans = 0.5*x*sqrt(x^2-1)-0.5*log(2*sqrt(x^2-1)+2*x)
subst()
.
If all fails, integrate numerically using quad
or romberg
.
expression
. Integrations can be quickly verified using diff()
on the result.