%% Definite Integrals of Symbolic Expressions
% Integrate a symbolic expression from 0 to 1.

syms x
expr = x*log(1+x);
F = int(expr,[0 1])

% Integrate another expression from sin(t) to 1.

syms t
F = int(2*x,[sin(t) 1])

% When int cannot compute the value of a definite integral, numerically approximate the integral by using vpa.

syms x
f = cos(x)/sqrt(1 + x^2);
Fint = int(f,x,[0 10])
Fvpa = vpa(Fint)

% To approximate integrals directly, use vpaintegral instead of vpa. The vpaintegral function is faster and provides control over integration tolerances.

Fvpaint = vpaintegral(f,x,[0 10])

%
% Copyright 2006-2019 The MathWorks, Inc.