-
Notifications
You must be signed in to change notification settings - Fork 954
Closed
Description
| $$ I = \int_{0}^{2} x^2 dx $$ |
While the interval of integration is [0, 2], corresponding sample code is as below:
raytracing.github.io/books/RayTracingTheRestOfYourLife.html
Lines 226 to 233 in 2460c2e
| int N = 1000000; | |
| double sum; | |
| for (int i = 0; i < N; i++) { | |
| auto x = random_double(0,2); | |
| sum += x*x; | |
| } | |
| std::cout << std::fixed << std::setprecision(12); | |
| std::cout << "I = " << sum/N << '\n'; |
Should sum/N be replaced to 2*sum/N?
TaoSc