You are on page 1of 2

INTEGRACIÓN NUMÉRICA

REGLA DEL TRAPECIO

#include<stdio.h>

#include<conio.h>

#include<math.h>

main()

int n,i;

float a,b,y,y1,y2,yf=0,Dx,dx,x;

printf("Este programa resuelve la integral de e^(x^2) en un intervalo [a,b]\n");

printf("\nIntroduce el valor de a: ");

scanf("%f",&a);

printf("\nIntroduce el valor de b: ");

scanf("%f",&b);

printf("\nIntervalos: ");

scanf("%d",&n);

float h[n];

dx=(b-a)/n;

for(i=1;i<n;i++)

{ x=a+i*dx;

h[i]=exp(pow(x,2));

y=y+h[i];

y1=exp(pow(a,2));

y2=exp(pow(b,2));

yf=((y1+y2+2*y)*dx)/2;

printf("\nEl valor aproximado de su integral con %d intervalos es: %f",n,yf);

getch();

MORENO GALLEGOS ULISES ALDAIR


MORENO GALLEGOS ULISES ALDAIR

You might also like