Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C++ Program to calculate Double Integration
We are given with the lower limit of variable x, upper limit of variable x, lower limit of variable y, upper limit of variable y, steps taken for corresponding x and steps taken for corresponding y and the task is to generate the double integration and display the result.
Example
Input-: steps for x = 1.2 steps for y = 0.54 lower limit of x = 1.3 upper limit of x = 2.1 lower limit of y = 1.0 upper limit for y = 2.1 Output-: double integration is : 2.1
Approach used in the below program is as follows −
- Input the value of upper and lower limit of x and y with that input the steps taken for x and y
- The method which we are using for calculating double integration for both x and y is Simpson 1/3 method
- Generate the following table before proceeding further

- Apply the simpson 1/3 rule to each row for first integral and repeat it twice for double integration
- Print the result
ALGORITHM
Start Step 1-> declare function to calculate power for integration float fun(float x, float y) return pow(pow(x, 4) + pow(y, 5), 0.5) Step 2-> declare function to find the double integral value float doubleIntegral(float step_x, float step_y, float lower_x, float upper_x, float lower_y, float upper_y) Declare int n1, n2 Declare float arr[50][50], arr_2[50], result set n1 = (upper_x - lower_x) / step_x + 1 set n2 = (upper_y - lower_y) / step_y + 1 Loop For int i = 0 and i In main() declare step for x as float step_x = 1.2 Declare step for y as float step_y = 0.54 Declare lower limit of xfloat lower_x = 1.3 Declare upper limit of xfloat upper_x = 2.1 Declare lower limit of yfloat lower_y = 1.0 Declare upper limit of yfloat upper_y = 2.1 Call (step_x, step_y, lower_x, upper_x, lower_y, upper_y) Stop
Example
#includeusing namespace std; float fun(float x, float y) { return pow(pow(x, 4) + pow(y, 5), 0.5); } // Function to find the double integral value float doubleIntegral(float step_x, float step_y, float lower_x, float upper_x, float lower_y, float upper_y) { int n1, n2; float arr[50][50], arr_2[50], result; n1 = (upper_x - lower_x) / step_x + 1; n2 = (upper_y - lower_y) / step_y + 1; for (int i = 0; i Output
double integration is : 2.1
Advertisements
