Hi guys, I am having trouble seeing where I have actually gone wrong with my code. If I run the code I am getting approximation of 12 as my lowest is way to big. But I am really struggling to find where I have gone wrong. Any advice would be appreciated.(adsbygoogle = window.adsbygoogle || []).push({});

Code (Fortran):

PROGRAM assign_10_1

IMPLICIT NONE

INTEGER, DIMENSION (1:12) :: SEED

REAL:: A,X,Y

INTEGER:: I, N, COUNTER_CIRCULE, COUNTER_SQUARE

COUNTER_CIRCULE=0

COUNTER_SQUARE=0

N=100000

WRITE(*,*)'please seclect 12 numbers for your seed'

READ(*,*) SEED

WRITE(*,*) SEED

CALL RANDOM_SEED(PUT=SEED)

DO I=1,N

CALL RANDOM_NUMBER(X)

CALL RANDOM_NUMBER(Y)

WRITE(*,*) X,Y

IF (X**2+Y**2 < 1) THEN

COUNTER_CIRCULE=COUNTER_CIRCULE+1

ELSE

COUNTER_SQUARE=COUNTER_SQUARE+1

END IF

END DO

A=4*(COUNTER_CIRCULE/COUNTER_SQUARE)

WRITE(*,*)'ESTIMATION FOR VALUE OF PI', A

END PROGRAM

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Monte Carlo Calculation of π

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads - Monte Carlo Calculation | Date |
---|---|

How to obtain a function from gsl library integration? | Nov 6, 2015 |

Free Energy calculation in Monte Carlo simulations | Apr 11, 2012 |

Calculating pi with Monte Carlo integration | Mar 29, 2012 |

Genetic Algorithms vs. Monte Carlo | Nov 17, 2010 |

Use of Monte Carlo Method to Solve Geometrical Problems in Radiation Transfer | Jan 11, 2010 |

**Physics Forums - The Fusion of Science and Community**