1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Fotran program to find half-life of a radioactive material

  1. Oct 13, 2012 #1
    1. The problem statement, all variables and given/known data
    I need to write a program that, given the decay constant of a radioactive material, will calculate numerically (to withing one second) the time taken for half of the orginal sample of material to decay.

    2. Relevant equations
    λ = decay constant C0 = start amount of material

    After one second C0 will have decayed leaving C = (1-λ)C0 of undecayed material left.

    3. The attempt at a solution
    I only have very basic experince at programming so I am finding this quite difficult. Below is the code that I have created so far.

    REAL :: y,C,t !y = decay constant C = starting amount of material t = time
    PRINT*,"Enter decay constant"
    PRINT*,"Enter starting amount of material"

    DO WHILE (C.GT.C/2)
    END DO


    I don't really have any idea how I would work out hiw many interations the DO WHILE loop has done which i need to kno in order to work out the half life.

    Any help/advice would be much appreciated.
  2. jcsd
  3. Oct 13, 2012 #2


    User Avatar

    Staff: Mentor

    It's helpful during the testing and debugging stage of writing a program to temporarily add a PRINT statement inside loops so that you can verify operation is exactly as you hope it will be.

    Suppose you were to add a PRINT statement inside your DO loop, what useful variables would you like it to print out?

    Imagine your program simulates the decay of 100 grams of material having a decay constant of 2.77 milliseconds. What are the first 6 of the output lines that your loop's added PRINT statement would print out?
    Last edited: Oct 13, 2012
  4. Oct 13, 2012 #3


    Staff: Mentor

    You'll need a variable to act as a counter that you can increment inside the do.while loop.

    Why not walk thru your algorithm step by step solving it on paper as if you were a computer?

    That should make it easier to design your loop and get your answer.

    What does each iteration of the do.while loop represent?
  5. Oct 14, 2012 #4
    Thanks for the replies :)

    I have managed to get the program to find the amount of undecayed substance left after the half life has been reached.

    Here is the new code:
    PROGRAM assignment1
    REAL :: y,C,t,v !y = decay constant C = starting amount of material t = time

    PRINT*,"Enter decay constant"
    PRINT*,"Enter starting amount of material"

    DO WHILE (C.GT.v/2)
    END DO

    PRINT*,"C =",C
    END PROGRAM assignment1

    I am not sure how I can get a varibale to act as counter inside the loop.
    Any help would be appreciated.
  6. Oct 14, 2012 #5


    Staff: Mentor

    do while (i.lt.10)
    print *,"i=",i
    end do
  7. Oct 14, 2012 #6
    Got it sorted now. Thanks for the help :smile:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook