%% Approximates the Integral of (5x^2-24x-12)/(x^3-4x) %% on the interval [3,5]. clc format compact format long g % Defining polynomials for the numerator and denominator p= [5 -24 -12] q = [1 0 -4 0] rp = roots(p) % Not really important rq = roots(q) [R,P,K] = residue(p,q) % Calculates the partial fraction decomposition % Begins integrals a=3, b=5 n1=10, n2=1000 dx1=(b-a)/n1 dx2=(b-a)/n2 % Constructs a list of midpoints x1=[a+dx1/2:dx1:b]; x2=[a+dx2/2:dx2:b]; % Plugs the values into the rational function y1=polyval(p,x1)./polyval(q,x1); y2=polyval(p,x2)./polyval(q,x2); sum1 = sum(y1)*dx1 sum2 = sum(y2)*dx2 exact = log(7^7/(3^8*5^4))