Evaluate integrals
release(expr)
example
release(expr) evaluates the integrals in the expression expr. The release function ignores the 'Hold' option in the int function when the integrals are defined.
expr
release
'Hold'
int
collapse all
Define a symbolic call to an integral ∫cos(x) dx without evaluating it. Set the 'Hold' option to true when defining the integral using the int function.
syms x F = int(cos(x),'Hold',true)
F = ∫cos(x)dxint(cos(x), x, 'Hold = TRUE', true)
∫cos(x)dxint(cos(x), x, 'Hold = TRUE', true)
Use release to evaluate the integral by ignoring the 'Hold' option.
G = release(F)
G = sin(x)sin(x)
Find the integral of ∫x ex dx.
Define the integral without evaluating it by setting the 'Hold' option to true.
true
syms x g(y) F = int(x*exp(x),'Hold',true)
F = ∫x exdxint(x*exp(x), x, 'Hold = TRUE', true)
∫x exdxint(x*exp(x), x, 'Hold = TRUE', true)
You can apply integration by parts to F by using the integrateByParts function. Use exp(x) as the differential to be integrated.
F
integrateByParts
exp(x)
G = integrateByParts(F,exp(x))
G = x ex-∫exdxx*exp(x) - int(exp(x), x, 'Hold = TRUE', true)
x ex-∫exdxx*exp(x) - int(exp(x), x, 'Hold = TRUE', true)
To evaluate the integral in G, use the release function to ignore the 'Hold' option.
G
Gcalc = release(G)
Gcalc = x ex-exx*exp(x) - exp(x)
Compare the result to the integration result returned by int without setting the 'Hold' option.
Fcalc = int(x*exp(x))
Fcalc = ex x-1exp(x)*(x - 1)
Find the integral of ∫cos(log(x))dx using integration by substitution.
syms x t F = int(cos(log(x)),'Hold',true)
F = ∫cos(log(x))dxint(cos(log(x)), x, 'Hold = TRUE', true)
∫cos(log(x))dxint(cos(log(x)), x, 'Hold = TRUE', true)
Substitute the expression log(x) with t.
log(x)
t
G = changeIntegrationVariable(F,log(x),t)
G = ∫et cos(t)dtint(exp(t)*cos(t), t, 'Hold = TRUE', true)
∫et cos(t)dtint(exp(t)*cos(t), t, 'Hold = TRUE', true)
H = release(G)
H = et cos(t)+sin(t)2(exp(t)*(cos(t) + sin(t)))/2
et cos(t)+sin(t)2(exp(t)*(cos(t) + sin(t)))/2
Restore log(x) in place of t.
H = simplify(subs(H,t,log(x)))
H = 2 x sin(π4+log(x))2(sqrt(sym(2))*x*sin(sym(pi)/4 + log(x)))/2
2 x sin(π4+log(x))2(sqrt(sym(2))*x*sin(sym(pi)/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 = 2 x sin(π4+log(x))2(sqrt(sym(2))*x*sin(sym(pi)/4 + log(x)))/2
Expression containing integrals, specified as a symbolic expression, function, vector, or matrix.
changeIntegrationVariable | diff | int | integrateByParts
changeIntegrationVariable
diff
You have a modified version of this example. Do you want to open this example with your edits?