Program for finding the Integral of a given function using Boole’s Rule
Given a function, f(x), tabulated at points
equally spaced by
- …..and so on
The upper and lower limits a, b correspond to which the integral needs to be found, the task is to find the integral value of the given equation f(x).
Input: a = 0, b = 4,
Integral of (1 / (1 + x)) is 4ln(|1 + x|)0 + c.
On substituting the limits, ln(|5|) + ln(|1|) = 1.6178.
Input: a = 0.2, b = 0.6,
Approach: In this article, Boole’s rule is discussed to compute the approximate integral value of the given function f(x).
Boole’s rule is a numerical integration technique to find the approximate value of the integral. It is named after a largely self-taught mathematician, philosopher, and logician George Boole. The idea of the Boole’s technique is to approximate the integral using the values of ‘fk‘ at some equally spaced values(h in the given image). The following illustration shows how various fk’s are considered:
The integral value of Boole’s rule is given by the formula:
- In the above formula, an error term which comes when integration is of order 6. The error term is
[Tex]f_1, f_2, f_3, f_4, f_5, [/Tex]
- Are the values of f(x) at their respective intervals of x.
- Therefore, the following steps can be followed to compute the integral of some function f(x) in the interval (a, b):
- The value of n=6, which is the number of parts the interval is divided into.
- Calculate the width, h = (b – a)/4.
- Calculate the values of x1 to x5 as
- Consider y = f(x). Now find the values
- for the corresponding
- Substitute all the values in Boole’s rule to calculate the integral value.
Below is the implementation of the above approach:
f(x) = 1.6178
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.