Let us learn how to implement Weddle’s rule algorithm in C programming with its explanation, output and much more.

#### What is Weddle’s Algorithm Rule?

The Weddle’s algorithm was designed by **Thomas Weddle**. This algorithm is a simple method of integration.

The number of sub intervals required in the Weddle’s rule is **6**. As compared to other numerical integration algorithms, the Weddle’s algorithm offers a very good efficiency.

#### Weddle’s Rule Formula

#### Weddle’s Rule Algorithm

1 2 3 4 5 6 7 8 9 10 | Step 1: Input Lower limit, Upper limit and Number of Intervals Step 2: Calculate Interval Gap (Interval Gap = (Upper limit - Lower limit) / Interval) Step 3: If(Interval % 6==0) sum = sum + ((3 * interval_gap / 10) * (y(Lower limit) + y(Lower limit + 2 * interval_gap) + 5 * y(Lower limit + interval_gap) + 6 * y(Lower limit + 3 * interval_gap) + y(Lower limit + 4 * interval_gap) + 5 * y(Lower limit + 5 * interval_gap) + y(Lower limit + 6 * interval_gap))); Lower limit = Lower limit + 6 * interval_gap; Go To Step 5. Else Weddle’s rule is not applicable Step 5: Evaluated Result |

**Note**: This C program for Weddle’s rule in numerical integration is compiled with GNU GCC compiler using CodeLite IDE on Microsoft Windows 10 operating system.

#### C Program For Weddle’s Rule Algorithm

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include<stdio.h> float calc(float temp) { float value; value = 1 / (1 + temp * temp); return (value); } int main() { int interval, limit, count = 0; float upper_limit, lower_limit, interval_gap, sum = 0; printf("\nLower Limit:\t"); scanf("%f", &lower_limit); printf("\nUpper Limit:\t"); scanf("%f", &upper_limit); printf("\nTotal Intervals:\t"); scanf("%d", &interval); interval_gap = (upper_limit - lower_limit) / interval; printf("\nInterval Gap:\t%f\n", interval_gap); limit = interval / 6; if(interval % 6 == 0) { while(count < limit) { sum = sum + ((3 * interval_gap / 10) * (calc(lower_limit) + calc(lower_limit + 2 * interval_gap) + 5 * calc(lower_limit + interval_gap) + 6 * calc(lower_limit + 3 * interval_gap) + calc(lower_limit + 4 * interval_gap) + 5 * calc(lower_limit + 5 * interval_gap) + calc(lower_limit + 6 * interval_gap))); lower_limit = lower_limit + 6 * interval_gap; count = count + 1; } printf("\nWeddle's Rule is satisfied.\n\nEvaluated Result:\t%f\n", sum); } else { printf("\nThe Weddle's Rule is not satisfied\n"); } return 0; } |

#### Output

If you have any doubts about the implementation of Weddle’s rule formula in C programming, let us know about it in the comment section. Find more about it on Wolfram.

Whats the relation between Simpson’s 3/8 rule and weddle’s rule?