**News Alert:**Experts Exchange Confirmed as Safe in Cloudbleed Leak Read More

Solved

Posted on 1998-11-22

hi there. the progrma consists in using the simpson 3/8 rule to

>calculate the integral of the following function: e^sinx from 1 to 3

>the rule for sypmpson is the following:

>

>I=(3/8)*(f1+3f2+3f3+2f4+3f5+3f6+2f7.....+3f20+3f21+f22)

>

> HERE I INCLUDE THE PROGRAM I MADE . IT RUNS BUT DOESNT GIVE THE

>RESULT TO THE INTEGRAL. IT SAYS IT IS zERO WHICH IS NOT.

>rules of the game:

>n=21, lower=1, upper=3, h= upper-lower/n, and I has to be a function.

>

>i will appreciate any help you can give me. this is for this monday.

>thanx,

>pedro

>

>

>#include<stdio.h>

>#include<math.h>

>void main (void)

>{

> float n,upper,lower,counter,counter2;

> float x1,acc,suma,f1,f2,f3,f4,Symp;

> float I(float,float);

> float h;

>

> acc=0;

> x1=1;

> counter=0;

> counter2=0;

> n=21.0000000000;

> lower=1.0000000000;

> upper=3.00000000;

> h=(upper-lower)/n;

>

> while(counter2<7)

> {

> f1=exp(sin(x1+(counter*h)));

> counter++;

> f2=exp(sin(x1+(counter*h)));

> counter++;

> f3=exp(sin(x1+(counter*h)));

> counter++;

> f4=exp(sin(x1+(counter*h)));

> suma=(f1+(3*f2)+(3*f3)+f4);

> acc+=suma;

> counter2=counter2+1;

> }

>

>Symp=I(h,acc);

>printf("sympson=%f",Symp);

>}

>

> float I(float w, float z)

>{

> float resultado;

> resultado=(3/8)*w*z;

> return (resultado);

>}

>

>calculate the integral of the following function: e^sinx from 1 to 3

>the rule for sypmpson is the following:

>

>I=(3/8)*(f1+3f2+3f3+2f4+3

>

> HERE I INCLUDE THE PROGRAM I MADE . IT RUNS BUT DOESNT GIVE THE

>RESULT TO THE INTEGRAL. IT SAYS IT IS zERO WHICH IS NOT.

>rules of the game:

>n=21, lower=1, upper=3, h= upper-lower/n, and I has to be a function.

>

>i will appreciate any help you can give me. this is for this monday.

>thanx,

>pedro

>

>

>#include<stdio.h>

>#include<math.h>

>void main (void)

>{

> float n,upper,lower,counter,coun

> float x1,acc,suma,f1,f2,f3,f4,Sy

> float I(float,float);

> float h;

>

> acc=0;

> x1=1;

> counter=0;

> counter2=0;

> n=21.0000000000;

> lower=1.0000000000;

> upper=3.00000000;

> h=(upper-lower)/n;

>

> while(counter2<7)

> {

> f1=exp(sin(x1+(counter*h))

> counter++;

> f2=exp(sin(x1+(counter*h))

> counter++;

> f3=exp(sin(x1+(counter*h))

> counter++;

> f4=exp(sin(x1+(counter*h))

> suma=(f1+(3*f2)+(3*f3)+f4)

> acc+=suma;

> counter2=counter2+1;

> }

>

>Symp=I(h,acc);

>printf("sympson=%f",Symp)

>}

>

> float I(float w, float z)

>{

> float resultado;

> resultado=(3/8)*w*z;

> return (resultado);

>}

>

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join the community of 500,000 technology professionals and ask your questions.