Main Content

changeIntegrationVariable

Integration by substitution

Since R2019b

Description

example

G = changeIntegrationVariable(F,old,new) applies integration by substitution to the integrals in F, in which old is replaced by new. old must depend on the previous integration variable of the integrals in F and new must depend on the new integration variable. For more information, see Integration by Substitution.

When specifying the integrals in F, you can return the unevaluated form of the integrals by using the int function with the 'Hold' option set to true. You can then use changeIntegrationVariable to show the steps of integration by substitution.

Examples

collapse all

Apply a change of variable to the definite integral abf(x+c)dx.

Define the integral.

syms f(x) y a b c
F = int(f(x+c),a,b)
F = 

abf(c+x) dx

Change the variable x+c in the integral to y.

G = changeIntegrationVariable(F,x+c,y)
G = 

a+cb+cf(y) dy

Find the integral of cos(log(x))dx using integration by substitution.

Define the integral without evaluating it by setting the 'Hold' option to true.

syms x t
F = int(cos(log(x)),'Hold',true)
F = 

cos(log(x)) dx

Substitute the expression log(x) with t.

G = changeIntegrationVariable(F,log(x),t) 
G = 

etcos(t) dt

To evaluate the integral in G, use the release function to ignore the 'Hold' option.

H = release(G)
H = 

etcos(t)+sin(t)2

Restore log(x) in place of t.

H = simplify(subs(H,t,log(x)))
H = 

2xsin(π4+log(x))2

Compare the result to the integration result returned by int without setting the 'Hold' option to true.

Fcalc = int(cos(log(x)))
Fcalc = 

2xsin(π4+log(x))2

Find the closed-form solution of the integral xtan(log(x))dx.

Define the integral using the int function.

syms x
F = int(x*tan(log(x)),x)
F = 

xtan(log(x)) dx

The int function cannot find the closed-form solution of the integral.

Substitute the expression log(x) with t. Apply integration by substitution.

syms t
G = changeIntegrationVariable(F,log(x),t)
G = 

e2t2Fhypergeom1(1,-i; 1-i; -e2ti)i2+et2+2i2Fhypergeom1(1,1-i; 2-i; -e2ti)-14-14i

The closed-form solution is expressed in terms of hypergeometric functions. For more details on hypergeometric functions, see hypergeom.

Compute the integral 01esin(x)dx numerically with high precision.

Define the integral 01esin(x)dx. A closed-form solution to the integral does not exist.

syms x
F = int(exp(sqrt(sin(x))),x,0,1)
F = 

01esin(x) dx

You can use vpa to compute the integral numerically to 10 significant digits.

F10 = vpa(F,10)
F10 = 1.944268879

Alternatively, you can use the vpaintegral function and specify the relative error tolerance.

Fvpa = vpaintegral(exp(sqrt(sin(x))),x,0,1,'RelTol',1e-10)
Fvpa = 1.944268879

The vpa function cannot find the numerical integration to 70 significant digits, and it returns the unevaluated integral in the form of vpaintegral.

F70 = vpa(F,70)
F70 = 1.944268879138581167466225761060083173280747314051712224507065962575967

To find the numerical integration with high precision, you can perform a change of variable. Substitute the expression sin(x) with t. Compute the integral numerically to 70 significant digits.

syms t;
G = changeIntegrationVariable(F,sqrt(sin(x)),t)
G = 

0sin(1)2tet1-t4 dt

G70 = vpa(G,70)
G70 = 1.944268879138581167466225761060083173280747314051712224507065962575967

Input Arguments

collapse all

Expression containing integrals, specified as a symbolic expression, function, vector, or matrix.

Subexpression to be substituted, specified as a symbolic scalar variable, expression, or function. old must depend on the previous integration variable of the integrals in F.

New subexpression, specified as a symbolic scalar variable, expression, or function. new must depend on the new integration variable.

More About

collapse all

Integration by Substitution

Mathematically, the substitution rule is formally defined for indefinite integrals as

f(g(x))g'(x)dx=(f(t)dt)|t=g(x)

and for definite integrals as

abf(g(x))g'(x)dx=g(a)g(b)f(t)dt.

Version History

Introduced in R2019b