%% Compute Definite Integral
% Compute the integral
% \int_0^2 \frac{1}{x^3-2x-5} dx .
% First, create an anonymous function myfun that computes the integrand.

myfun = @(x) 1./(x.^3-2*x-5);

%
% Now use quad to compute the integral. Specify the limits of integration as the second and third input arguments.

q = quad(myfun,0,2)

%
% Alternatively, you can pass the integrand to quad by creating a function file:
% function y = myfun(x)
%   y = 1./(x.^3-2*x-5);
% end
% With this method, the call to quad becomes quad(@myfun,0,2).
%
% Copyright 2020 The MathWorks, Inc.