The midpoint rule works by choosing midpoint values of $x$ and finding the area under the curve by approximating using rectangles. An image below is shown to illustrate the idea:
The higher dimension version of this is with double integrals, where the integral is approximated using rectangular prisms, where the rectangular prism's height is $f(\overline{x}, \overline{y})$, and the area of the base is $\Delta x \Delta y$.
Here's an image for some clarity on how it works:
Thus the area of the individual prism is $f(\overline{x}, \overline{y})\Delta x \Delta y$. Here's the code:
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 41 42 43 44 45 46 

What this code does is that it manually splits up the $x$ and $y$ domain we are integrating on into very small parts, and computes the volumes of the rectangular prisms that is resulted from that.
It gets the value of the midpoints, and finds the values of the functions at that point, and multiplies by the small crosssection area of the rectangular prism.
It later sums up all the values of the volumes to end up at the value of the double integral. Try the code out for yourself.
To point you out some resources, I learnt this from Stewart Calculus Early Transcendentals.
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Sort by:
Top Newest@Krishna Karthik sir i am getting wrong answer for this problem
$\int_{0}^{2} \int_{0}^{1} x^{2} y^{3} dxdy$
Log in to reply
Don't have to call me sir bro, I am younger than you.
Log in to reply
@Krishna Karthik as you are guiding me so much therefore .
Log in to reply
Log in to reply
I know where you copied the code wrong. In the function definition, you have used "i" and "j". Instead use letters "p" and "q" because those are the arguments the function uses.
Log in to reply
@Krishna Karthik i have typed the whole code.
the above double integral have two variables x and y and like that the double integral which we were evaluating have p and q ??
am i right ??
after correcting that line as p and q ,still i am getting wrong answer .
Log in to reply
Log in to reply
thanks in advance .
Log in to reply
Log in to reply
@Krishna Karthik i was just typing the code beacause i want to increase my typing speed and to memorise the code
Log in to reply
Log in to reply
Log in to reply
@Krishna Karthik thanks i agree with you.
cheers!
Log in to reply
Log in to reply
Log in to reply
@Krishna Karthik what is the meaning of hard coding ??
Log in to reply
Log in to reply
@Krishna Karthik after copying the code still i am getting $0.888888$ as answer.
Log in to reply
Did you get the correct answer? I edited the code above now and realised the error; use the code above :)
Log in to reply
@Krishna Karthik now the current has come and i checked ,
now i am getting correct answer. thanks
sorry for the late reply.
btw can we solve 4 integrals also?
if yes 5 also ??
can you tell me your PC specs
thanks in advance.
Log in to reply
I have two PCs that I use; one is a mac with Intel i7 processor, and my best PC is a Windows 10 gaming PC with i7 processor (2.9 Ghz) and GeForce GTX 1070 GPU. It has 32 GB RAM.
Log in to reply
@Krishna Karthik i also like to play games.
Do you play PUBG(MOBILE)??, I play but very rarely.
If yes, we will play 12 matches.
Log in to reply
Log in to reply
Log in to reply
@Krishna Karthik Sorry sir .
I only play one game and it's pubg twice a week, or even doesn't play.
I doesn't know how to download it in PC.
Btw Can we play 1 match in mobile?
Log in to reply
Log in to reply
@Krishna Karthik can you guide me to download it in PC in best way.
In YouTube there are so many video and they all tell different ways to download, which gets very messy.
Thanks in advance
Log in to reply
If you do have a beast PC, you should be able to play it. I think I'll download mobile. There's no need to download PC and spends 40 dollars lol
Log in to reply
@Krishna Karthik yes sir i agree with you.
can you download PUBG MOBILE in computer ??
after that i will also download .
Log in to reply
@Krishna Karthik here below my python code is attached ,i have copied the whole code
Log in to reply
I have added the comments. Meanwhile I will figure out the error :)
Log in to reply
Oh, I have figured out the error in my code; the function was copied as $x^2 y^2$, not $x^2 y^3$, it was my error, soz. Have a go with the new code above! :)
Log in to reply
The code should be working perfectly now; I have modified the function with the right expression.
Log in to reply
@Krishna Karthik sir can you make a guide that how to evaluate integrals using Simpson $1/3$ and $1/8$ rule.
Thanks in advance
Log in to reply
Alright. I'll do it soon and show you.
Log in to reply