Integración

Método del punto medio

El procedimiento numérico que vamos a utilizar para obtener la integral definida va a ser el del 'punto medio'.

Vamos a aproximar la integral definida a b f(x)dx , sumando las áreas de cada uno de los rectángulos.

El área del rectángulo de la figura es f(xm)(xi+1-xi)= f(xm)Δxi, donde xm es el punto medio

Para ello definimos la función Integral

function suma = Integral( f, x )
    suma=0;
    for  i=1:length(x)-1
        xm=(x(i+1)+x(i))/2;
        suma=suma+f(xm)*(x(i+1)-x(i));
    end
end

Ejemplos

Integración numérica con funciones MATLAB

La función integral nos da el valor aproximado de la integral cuando le introducimos la función a integrar y los límites de integración.

q=integral(function, a, b);

NOTA.- L a x funciona como vector en integral no olvidar el (.)

Ejercicios

  1. 1 2 ( x 2 -2x+3)dx

  2. >> f=@(x) x.^2-2*x+3;
    >> q=integral(f,1,2)
    q =    2.3333

    Con el procedimiento del punto medio

    >> f=@(x) x^2-2*x+3;
    >> x=linspace(1,2,200);
    >> Integral(f,x)
    ans =    2.3333
  3. 0 8 ( 2x + x 3 )dx

  4. >> f=@(x) sqrt(2*x)+nthroot(x,3);
    >> q=integral(f,0,8)
    q =   33.3333

    Con el procedimiento del punto medio

    >> f=@(x) sqrt(2*x)+nthroot(x,3);
    >> x=linspace(0,8,300);
    >> Integral(f,x)
    ans =   33.3342
    >> x=linspace(0,8,3000);
    >> Integral(f,x)
    ans =   33.3334
    >> x=linspace(0,8,30000);
    >> Integral(f,x)
    ans =   33.3333
    >> x=0:0.0001:8;
    >> suma=Integral(f,x)
    suma =   33.3333
  5. 1 4 1+ x x 2 dx

  6. >> f=@(x) (1+sqrt(x))./x.^2;
    >> q=integral(f,1,4)
    q =   1.7500

    Con el procedimiento del punto medio

    >> f=@(x) (1+sqrt(x))/x^2;
    >> x=linspace(1,4,1000);
    >> Integral(f,x)
    ans =    1.7500
    >> f=@(x) (1+sqrt(x))/x^2;
    >> x=1:0.0001:4;
    >> suma=Integral(f,x)
    suma =    1.7500
  7. 2 6 x-2 dx

  8. >> f=@(x) sqrt(x-2);
    >> q=integral(f,2,6)
    q =    5.3333

    Con el procedimiento del punto medio

    >> f=@(x) sqrt(x-2);
    >> x=linspace(2,6,1000);
    >> Integral(f,x)
    ans =    5.3333
  9. 0 -3 dx 25+3x

  10. >> f=@(x) 1./ sqrt(25+3*x);
    >> q=integral(f,0,-3)
    q =   -0.6667

    Con el procedimiento del punto medio

    >> f=@(x) 1/ sqrt(25+3*x);
    >> x=linspace(0,-3,1000);
    >> Integral(f,x)
    ans =     -0.6667
  11. -2 -3 dx x 2 -1

  12. >> f=@(x) 1./ (x.^2-1);
    >> q=integral(f,-2,-3)
    q =   -0.2027

    Con el procedimiento del punto medio

    >> f=@(x) 1/ (x^2-1);
    >> x=linspace(-2,-3,1000);
    >> Integral(f,x)
    ans =   -0.2027
  13. 0 1 xdx x 2 +3x+2

  14. >> f=@(x) x./(x.^2+3*x+2);
    >> q=integral(f,0,1)
    q =    0.1178

    Con el procedimiento del punto medio

    >> f=@(x) x/(x^2+3*x+2);
    >> x=linspace(0,1,1000);
    >> Integral(f,x)
    ans =    0.1178
  15. -1 1 x 5 x+2 dx

  16. >> f=@(x) x.^5./(x+2);
    >> q=integral(f,-1,1)
    q =   -0.0889

    Con el procedimiento del punto medio

    >> f=@(x) x^5/(x+2);
    >> x=linspace(-1,1,1000);
    >> Integral(f,x)
    ans =   -0.0889
  17. 0 1 dx x 2 +4x+5

  18. >> f=@(x) (x.^2+4*x+5).^(-1);
    >> a=integral(f,0,1)
    a =    0.1419

    Con el procedimiento del punto medio

    >> x=linspace(0,1,200);
    >> suma=Integral(f,x)
    suma =    0.1419
  19. π 6 π 4 1 co s 2 xdx

  20. >> f=@(x) 1./(cos(x)).^2;
    >> q=integral(f,pi/6,pi/4)
    q =    0.4226

    Con el procedimiento del punto medio

    >> f=@(x) 1/(cos(x))^2;
    >> x=linspace(pi/6,pi/4,1000);
    >> Integral(f,x)
    ans =    0.4226
  21. 1 e sen(lnx) x dx

  22. >> f=@(x) sin(log(x))./x;
    >> a=integral(f,1,exp(1))
    a =    0.4597

    Con el procedimiento del punto medio

    >> x=linspace(1,exp(1),100);
    >> suma=Integral(f,x)
    suma =    0.4597

Integrales indefinidas con simbólico

  1. 13+lnx 6 x dx

  2. >> syms x
    >> y=((13+log(x))^(1/6))/x;
    >> a=int(y)
    a = (6*(log(x) + 13)^(7/6))/7
    >> b=diff(a) 
    b =(log(x) + 13)^(1/6)/x
  3. dx ( x 2 4x+3)(x+5)

  4. >> y=(x^2-4*x+3)^-1*(x+5)^-1;
    >> z=int(y)
    z =log(x - 3)/16 - log(x - 1)/12 + log(x + 5)/48.
    >> diff(z)
    ans =1/(16*(x - 3)) - 1/(12*(x - 1)) + 1/(48*(x + 5)) 
    >> simplify(ans) 
    ans =1/((x - 1)*(x - 3)*(x + 5))
  5. dx (x1)(x2)(x+4)

  6. >> y=(x-1)^-1*(x-2)^-1*(x+4)^-1;
    >> z=int(y)
    z =log(x - 2)/6 - log(x - 1)/5 + log(x + 4)/3
    >> y=diff(z) 
    y = 1/(6*(x - 2)) - 1/(5*(x - 1)) + 1/(30*(x + 4))
    >> simplify(y)
    ans =1/((x - 1)*(x - 2)*(x + 4))
  7. 5 x 4 x 3 5 x 2 +4x dx

  8. >> y=5*x^4/(x^3-5*x^2+4*x);
    z=int(y) 
    z = 25*x - (5*log(x - 1))/3 + (320*log(x - 4))/3 + (5*x^2)/2
    >> y=diff(z)
    y =5*x - 5/(3*(x - 1)) + 320/(3*(x - 4)) + 25
    >> simplify(y) 
    ans = (5*x^3)/(x^2 - 5*x + 4)
  9. 2 x 2 +1 x 3 6 x 2 +11x6 dx

  10. >> y=(2*x^2+1)/(x^3-6*x^2+11*x-6);
    >> z=int(y)
    z = (3*log(x - 1))/2 - 9*log(x - 2) + (19*log(x - 3))/2
    >> y=diff(z) 
    y =3/(2*(x - 1)) - 9/(x - 2) + 19/(2*(x - 3))
  11. dx 3 x 2 x+1

  12. >> y=(3*x^2-x+1)^-1;
    >> z=int(y)
    z = (2*11^(1/2)*atan((11^(1/2)*(6*x - 1))/11))/11 
    >> diff(z) 
    ans =12/(11*((6*x - 1)^2/11 + 1))
  13. xdx x 2 7x+13

  14. >> y=x/(x^2-7*x+13);
    >> z=int(y)
    z = log(x^2 - 7*x + 13)/2 + (7*3^(1/2)*atan((2*3^(1/2)*x)/3 - (7*3^(1/2))/3))/3
    >> simplify(z)
    ans =log(x^2 - 7*x + 13)/2 + (7*3^(1/2)*atan(3^(1/2)*((2*x)/3 - 7/3)))/3 
    >> y=diff(ans) 
    y =(2*x - 7)/(2*(x^2 - 7*x + 13)) + 14/(3*(3*((2*x)/3 - 7/3)^2 + 1))
    >> simplify(y) 
    ans = x/(x^2 - 7*x + 13)
  15. x 4 x 4 1 dx

  16. >> y=x^4/(x^4-1);
    >> z=int(y)
    z = x - atan(x)/2 - atanh(x)/2
    >> y=diff(z)
    y =1/(2*(x^2 - 1)) - 1/(2*(x^2 + 1)) + 1
    >> simplify(y) 
    ans =x^4/(x^4 - 1)
  17. x 3 + x 2 +x+3 ( x 2 +1)( x 2 +3) dx

  18. >> y=(x^3+x^2+x+3)/((x^2+1)*(x^2+3));
    >> z=int(y) 
    z = log(x^2 + 3)/2 + atan(x)
    >> y=diff(z)
    y =x/(x^2 + 3) + 1/(x^2 + 1)
  19. dx x 3 +1

  20. >> y=1/(x^3+1);
    >> z=int(y) 
    z =log(x + 1)/3 - log((x - 1/2)^2 + 3/4)/6 + 
    (3^(1/2)*atan((2*3^(1/2)*(x - 1/2))/3))/3 
    >> y=diff(z)
    y = 1/(3*(x + 1)) + 2/(3*((4*(x - 1/2)^2)/3 + 1)) - 
    (2*x - 1)/(6*((x - 1/2)^2 + 3/4))
    >> simplify(y) 
    ans = 1/(x^3 + 1)
  21. sen 4 xdx

  22. >> y=(sin(x))^4;
    >> z=int(y) 
    z =(3*x)/8 - sin(2*x)/4 + sin(4*x)/32 
    >> y=diff(z) 
    y = cos(4*x)/8 - cos(2*x)/2 + 3/8 
    >> simplify(y) 
    ans = (cos(2*x) - 1)^2/4 
    >> expand(ans) 
    ans = cos(x)^4 - 2*cos(x)^2 + 1
    >> simplify(ans)
    ans =(cos(x)^2 - 1)^2 =(-sin(x)^2)^2=sin(x)^4
  23. 1 x 2 dx

  24. >> y=sqrt(1-x^2);
    >> z=int(y)
    z = asin(x)/2 + (x*(1 - x^2)^(1/2))/2
    >> y=diff(z)
    y = 1/(2*(1 - x^2)^(1/2)) - x^2/(2*(1 - x^2)^(1/2)) + (1 - x^2)^(1/2)/2
    >> simplify(y) 
    ans = (1 - x^2)^(1/2)
  25. x 2 +6x7 dx

  26. >> y=sqrt(x^2+6*x-7);
    >> z=int(y)
    z =(x/2 + 3/2)*(x^2 + 6*x - 7)^(1/2) - 8*log(x + (x^2 + 6*x - 7)^(1/2) + 3)
    >> y=diff(z) 
    y =(x^2 + 6*x - 7)^(1/2)/2 - (8*((2*x + 6)/(2*(x^2 + 6*x - 7)^(1/2)) + 1))
    /(x + (x^2 + 6*x - 7)^(1/2) + 3) + ((2*x + 6)*(x/2 + 3/2))
    /(2*(x^2 + 6*x - 7)^(1/2))
    >> simplify(y) 
    ans =(x^2 + 6*x - 7)^(1/2)
  27. x·arctg( x 2 +9 9 )dx

  28. >> y=x*atan((x^2+9)/9);
    >> z=int(y) 
    z = (9*atan(x^2/9 + 1))/2 - (9*log(x^4 + 18*x^2 + 162))/4 + 
    (x^2*atan(x^2/9 + 1))/2 
    >> y=diff(z) 
    y = x/((x^2/9 + 1)^2 + 1) - (9*(4*x^3 + 36*x))/(4*(x^4 + 18*x^2 + 162)) 
    + x*atan(x^2/9 + 1) + x^3/(9*((x^2/9 + 1)^2 + 1))
    >> simplify(y) 
    ans = x*atan(x^2/9 + 1)