Interesting. For me, the G(1,1,0) call returned 0.333 but multiplying by 3!/(3-1)! changed it to 2.00 .
BTW my computer is i7 @ 2.3GHz. RAM or number of cores don't really matter here.
Unfortunately I don't have it here, I did it at work. But I rewrote your Python program pretty much 1:1.
I guess it doesn't help that you carry around all the parameters. It would be better to declare K, M, dx, dy as constants as you did in Python (using #define).
I remember I added a test at...
I've rewritten your code to C. It took like 20 seconds to run with 0.001 .
I'm not all that good with statistics but it seems the sort function is somehow missing in the other version. Are you sure that the first formula in #29 is correct?
As the saying goes, you'll find the helping hand at the end of your arm.
After 5 minutes of debugging, it seems that you need to reset ux to x_prev_lim inside the uy-loop rather than before it.
Now I'm getting 1.999329 with the code you posted, or 1.999993 with dx & dy=0.001. Are you using K=3...
In the first formula, is it missing ##f_Y(y_2)## somewhere? Where do the ##z_i## come from? Where does the x/y in the second formula come from?
What result do you get, and how it changes if you use smaller dx & dy?
Do you know if the MC simulation is correct?
But seriously, if you want to make...
I meant something like this
res = 0
u = h/2 #prev_lim
while u <= max(prev_lim, h-prev_lim):
res += G(max(prev_lim, h-prev_lim), m+1, u)*f(u)*du
res += G(max(prev_lim, h-prev_lim), m+1, h-u)*f(h-u)*du
u += du
but now it doesn't seem...
The last sample needs to have weight 1 as well. So it's 1, 4, 2, 4, 2, ..., 2, 4, 1. Also make sure that the number of samples is even (perhaps by tweaking du a bit before the loop, or starting at u=h/2 and going both ways at once).
You may first want to let it run with small du to make sure that it works now, before optimizing.
You can play with du a bit but it will always be a trade between speed and accuracy.
Then you can try Simpson's rule, that's reasonably simple and improves accuracy even with bigger du. Requires...
Here on PF I often read that the Schrödinger's cat doesn't work, but never understood why.
Is the objection only that the box is usually not perfect? It is obviously assumed that the box is perfect, otherwise there's no point in having a box in the first place.
If we could measure something that...
Different observers won't agree on simultaneity, precisely because it does not affect anything. It's only a viewpoint.
My neural state is defined by neuron charges and dendrite weights. These are the same whether viewed by myself or some fast alien.
If someone says that I saw something, they'll...
Maybe one of them saw what's behind me, and neither I nor the other observer saw it.
If the two observers are somewhat intelligent, they'll undestand that they only view some part of the full truth. So do I. But their view may be more complete and more correct than mine.
Maybe you're misunderstanding the "relativity" in Theory of relativity.
Let's imagine you and I go to view some play in a theater. Your seat is more to the left, mine is more to the right. We both see the same thing, yet it looks different. Both of our views are equally correct. There is no...