If statement for Monte Carlo integration

mayankbhargava101
Messages
1
Reaction score
0
Hello,

I am writing a program on Fortran to calculate the integral of sin^4(x) between x = 0 and x = π/2.

I believe I know how to write the correct code, but I am unsure what the if statement should be for whether or not a point is inside the desired area.

Any thoughts?

Thanks.
 
Technology news on Phys.org
mayankbhargava101 said:
Hello,

I am writing a program on Fortran to calculate the integral of sin^4(x) between x = 0 and x = π/2.

I believe I know how to write the correct code, but I am unsure what the if statement should be for whether or not a point is inside the desired area.

Any thoughts?

Thanks.
I assume that you are generating random points within a bounding rectangle. Since you are calculating an integral, you will want the area under the curve. The operative phrase would be "under the curve".
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
67
Views
9K