Generally I understand the idea of the Monte Carlo method.
However, when I read articles about it, there is always shown an example of calculating pi using a square, into which we insert 1/4th of a circle. Then we start putting randomly points into the square, and because the area of a 1/4 of the circle is pi/4, and the area of the square is exactly 1, we get that pi/4 = number of points in the circle / number of points in the square.
This simple example had been obvious for me, I'd liked it much, but one day I realized, that this gives correct (with some error of course) results because we know exactly what we want to get. So in this example we know that this square should be 1-sized.
Let us consider we know nothing about the function (in this case the circle) so we don't know which borders to choose. If we mistakenly take a 2x2 square, we won't get good result.
Ok, so we should first find the square. To find a square we need the function values, at least max and min. So I need to search them. But searching increases complexity. If I check each value for each x why just don't perform numerical integration in the same loop?
I understand the example of searching pi is trivial, however for me this does not make sense as we know how to fit data to get desired result.
(Please note I'm not a mathematician, but an engineer so I have some basis in maths, but I'm not good in advanced problems)