Numerical Integration by Weddle's Rule: Page No ...

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

SEM 6 – CC-14 Numerical Methods Practical 2021

Problem No: WEDL - 21 Page No…...…….

Numerical Integration by
Weddle’s Rule

Write a C-Program to compute the value of the following integral correct to 8 decimal places
by Weddle’s rule using 19 ordinates:

where 2.1

NAME : PRABHAKAR SONAR


ROLL NO : 183613-21-0045
DATE : 01/07/2021
WORKING FORMULA :

Since xi’s are equally spaced , so for integrating the given function we use COMPOSITE
WEDDLE’S RULE, as it is,
𝑏
3ℎ
𝑓 𝑥 𝑑𝑥 = [ 𝑦 + 𝑦𝑛 + 5(𝑦1 + 𝑦5 + 𝑦7 + ⋯ + 𝑦𝑛−1 ) + 𝑦2 + 𝑦4 + ⋯ + 𝑦𝑛−2
𝑎 10 0
+ 6 𝑦3 + 𝑦9 + 𝑦15 + ⋯ + 𝑦𝑛−3 + 2(𝑦6 + 𝑦12 + 𝑦18 + ⋯ + 𝑦𝑛−6 )]

Where

n ≥ 12

𝑏−𝑎
h=
𝑛

𝑦𝑟 = 𝑓 𝑥𝑟

𝑥𝑟 = 𝑥0 + 𝑟ℎ ; 𝑟 = 0,1, … , 𝑛.

𝑥0 = 𝑎 , 𝑥𝑛 = 𝑏.

n = No of sub-intervals between xi’s.


/*CC-14 Numerical Methods Practical 2021
NAME: PRABHAKAR SONAR
CU ROLL NO: 183613-21-0045
PROGRAM FOR WEDDLE RULE
PROGRAM NO: WEDL - 21
Date Of Submission: 01/07/2021*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
double f(double x)
{
double g;
g=(log(1+(2.1*x)+pow(x,3)))/(exp(sqrt(x))+2.1);
return(g);
}
main()
{
double x,a,b,h,I,sum1=0,sum2=0,sum3=0,sum4=0;
int i,n,m;
clrscr();
printf("Enter the value of lower limit : ");
scanf("%lf",&a);
printf("Enter the value of upper limit : ");
scanf("%lf",&b);
printf("Enter the no of sub-intervals n : ");
scanf("%d",&n);
h=(b-a)/n;
m=n/6.0;
for(i=1;i<=m;i++)
{
x=a+(6*i-4)*h;
sum1+=f(x);
x=a+(6*i-2)*h;
sum1+=f(x);
x=a+(6*i-5)*h;
sum2+=f(x);
x=a+(6*i-1)*h;
sum2+=f(x);
x=a+(6*i-3)*h;
sum3+=f(x);
if(i!=1)
{
x=a+(6*i-6)*h;
sum4+=f(x);
}
}
I=(3*h/10.0)*(f(a)+f(b)+(5*sum2)+sum1+(6*sum3)+(2*sum4));
printf("The value of Integration is : %1.8lf",I);
getch();
}

OUTPUT :

Enter the value of lower limit : 1


Enter the value of upper limit : 5
Enter the no of sub-intervals n : 18
The value of Integration is : 1.70203577

You might also like