# Fortran 90 Euler Scheme for Radioactive Decay

• Comp Sci
• ksx2098
N+1)?In summary, the conversation discusses writing a Fortran 90 program to solve a differential equation for the decay of a radioactive substance using the Euler scheme. The equation and values are provided, and the attempt at a solution includes setting initial values and calculating x with time using a DO loop. The potential issue with the DO loop is mentioned.
ksx2098

## Homework Statement

in fortran 90 write a program to using the euler scheme to solve the differential equation for decay of a radioactive substance

dx/dt = -j*x

solving the equation we get

x = e^(-j*t)

following info is given

2. Homework Equations and values

t0 = 0.0
tF = 10.0
tStep = 0.1
x(0) = 1+0i
j = 3.0

## The Attempt at a Solution

Code:
PROGRAM EULER
!
INTEGER :: I,N
REAL :: t, x
REAL, PARAMETER :: t0 = 0.0, tF = 10.0, tStep = 0.1, j = 3.0
!
!Calc N
!
N = INT((tF-t0)/tStep + SPACING((tF-t0)/tStep)) + 1 ! trip count
!
!set initial values
!
t = t0
x = 0.0
!
!Calculate x with time
!
DO I + 1, N+1
PRINT *, t, x
x = x + tStep * f(x,t)
t = t + tStep
ENDDO
!
END PROGRAM EULER
!
FUNCTION f(x,t)
!
REAL :: t, x
REAL, PARAMETER :: j = 3.0
!
f = EXP( -1.0 * j * t)
!
END FUNCTION f(x,t)

no errors upon compiling

my x value ends up being 2*t

i think the problem is in the DO loop

Shouldn't DO I + 1, N+1
be Do I=1,N+1

.

Your attempt at solving this problem using the Euler scheme for radioactive decay is a good start. However, there are a few things that can be improved upon.

Firstly, in the DO loop, the counter variable I should start from 0 instead of 1. This is because the initial value of x is given at t=0, so we need to account for that in our loop.

Secondly, the function f(x,t) should take into account the decay constant j, which is given as 3.0 in the problem statement. So the correct function should be f(x,t) = -j*x.

Thirdly, the initial value of x is given as 1+0i, which implies that x is a complex number. However, in your code, x is declared as a real number. You can declare it as a complex number using the COMPLEX data type in Fortran.

Lastly, the Euler scheme is an approximation method and it is not very accurate for solving differential equations. It would be better to use a more accurate method like the Runge-Kutta method.

Overall, your attempt is a good start, but it can be improved upon by taking into account these suggestions.

## 1. What is the Fortran 90 Euler Scheme?

The Fortran 90 Euler Scheme is a numerical method used to solve differential equations, specifically in the field of radioactive decay. It is a first-order approximation that uses small time steps to approximate the solution to a differential equation.

## 2. How does the Fortran 90 Euler Scheme work?

The Fortran 90 Euler Scheme works by using a small time step to approximate the solution to a differential equation. It involves using the Euler method, which uses the current value and the slope at that point to estimate the next value. This process is repeated for each time step until the desired solution is reached.

## 3. What is the significance of using the Fortran 90 Euler Scheme for radioactive decay?

The Fortran 90 Euler Scheme is significant for radioactive decay because it allows for a numerical solution to be obtained, rather than relying on analytical solutions which may not always be feasible. It also allows for the simulation of decay processes over a longer period of time, as it can handle a large number of time steps.

## 4. Are there any limitations to using the Fortran 90 Euler Scheme for radioactive decay?

Yes, there are some limitations to using the Fortran 90 Euler Scheme for radioactive decay. It is a first-order approximation, so it may not be as accurate as higher-order methods. It also assumes a constant decay rate, which may not always be the case in real-world scenarios.

## 5. Can the Fortran 90 Euler Scheme be used for other applications besides radioactive decay?

Yes, the Fortran 90 Euler Scheme can be used for other applications besides radioactive decay. It is a general numerical method that can be applied to various differential equations, such as those in physics, engineering, and economics. However, it may not always be the most efficient or accurate method for certain applications.

• Engineering and Comp Sci Homework Help
Replies
8
Views
2K
• Engineering and Comp Sci Homework Help
Replies
4
Views
1K
• Programming and Computer Science
Replies
4
Views
1K
• Programming and Computer Science
Replies
4
Views
977
• Engineering and Comp Sci Homework Help
Replies
1
Views
2K
• Engineering and Comp Sci Homework Help
Replies
2
Views
8K
• Engineering and Comp Sci Homework Help
Replies
1
Views
2K
• Differential Equations
Replies
1
Views
1K
• Programming and Computer Science
Replies
8
Views
1K
• Engineering and Comp Sci Homework Help
Replies
5
Views
5K