Write a program to calculate double integral numerically.
Input: Given the following integral. where Output: 3.915905
Explanation and Approach:
- We need to decide what method we are going to use to solve the integral.
In this example, we are going to use Simpson 1/3 method for both x and y integration.
To do so, first, we need to decide the step size. Let h be the step size for integration with respect to x and k be the step size for integration with respect to y.
We are taking h=0.1 and k=0.15 in this example.
Refer for Simpson 1/3 rule
- We need to create a table which consists of the value of function f(x, y) for all possible combination of all x and y points.
x\y y0 y1 y2 …. ym x0 f(x0, y0) f(x0, y1) f(x0, y2) …. f(x0, ym) x1 f(x1, y0) f(x1, y1) f(x1, y2) …. f(x1, ym) x2 f(x2, y0) f(x2, y1) f(x2, y2) …. f(x2, ym) x3 f(x3, y0) f(x3, y1) f(x3, y2) …. f(x3, ym) …. …. …. …. …. …. …. …. …. …. …. …. xn f(xn, y0) f(xn, y1) f(xn, y2) …. f(xn, ym)
In the given problem,
x0=2.3 x2=2.4 x3=3.5 y0=3.7 y1=3.85 y2=4 y3=4.15 y4=4.3
- After generating the table, we apply Simpson 1/3 rule (or whatever rule is asked in the problem) on each row of the table to find integral wrt y at each x and store the values in an array ax.
- We again apply Simpson 1/3 rule(or whatever rule asked) on the values of array ax to calculate the integral wrt x.
Below is the implementation of the above code:
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.
- Program to find the indefinite Integration of the given Polynomial
- Program to calculate Profit Or Loss
- Program to calculate distance between two points in 3 D
- Program to calculate the area between two Concentric Circles
- Program to calculate area of an Circle inscribed in a Square
- Program to calculate the Surface Area of a Triangular Prism
- Program to calculate the number of odd days in given number of years
- C Program to Add two Integers
- Program to find greater value between a^n and b^n
- Program to check if two strings are same or not
- Writing first C++ program : Hello World example
- Program to Print K using Alphabets
- Program to differentiate the given Polynomial
- Program to print window pattern
- Program to find the Nth term of series -1, 2, 11, 26, 47......
- Program to find Nth term of series 9, 23, 45, 75, 113...
- C Program to Check Whether a Number is Prime or not
- Program to find N-th term of series 3, 5, 33, 35, 53....
- Difference between Algorithm, Pseudocode and Program
- C program to find the length of a string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.