- #1
sayellow
- 1
- 0
Euler Method in Fortran - HELP!
Using Euler method I want to calculate the equation below, deltat=0.3, 10 times.
Problem: When n=1, Yn1(1) is calculated right. But, in the following steps it should assume that Yn(2)=Yn1(1) and the program is assuming Yn(2)=0, as well as Yn(3)=0,...and so on
Please, can someone help me?
Program Exercise1
!
! This Program will solve the ODE bellow using Euler Method ...
!
! dy(t)
! ______ = 2y(t) + t^2 + t
! dt
!
! Declaration of Variables
!
Implicit none
!
!
Real:: deltat1
Integer:: ts1,n,time
Real:: Yn1(1:11),Yn(1:11),tn(1:11)
Yn(1)=1
do n=1,ts1
deltat=0.3
ts1=10
tn(n)=(deltat*(n-1))+tn(n)
Yn1(n+1)=Yn(n)+deltat*(2*Yn(n)+(tn(n)**2)+tn(n))
Yn(n)=Yn1(n+1)
write (*,*) Yn1(n)
enddo
n=n+1
End
Using Euler method I want to calculate the equation below, deltat=0.3, 10 times.
Problem: When n=1, Yn1(1) is calculated right. But, in the following steps it should assume that Yn(2)=Yn1(1) and the program is assuming Yn(2)=0, as well as Yn(3)=0,...and so on
Please, can someone help me?
Program Exercise1
!
! This Program will solve the ODE bellow using Euler Method ...
!
! dy(t)
! ______ = 2y(t) + t^2 + t
! dt
!
! Declaration of Variables
!
Implicit none
!
!
Real:: deltat1
Integer:: ts1,n,time
Real:: Yn1(1:11),Yn(1:11),tn(1:11)
Yn(1)=1
do n=1,ts1
deltat=0.3
ts1=10
tn(n)=(deltat*(n-1))+tn(n)
Yn1(n+1)=Yn(n)+deltat*(2*Yn(n)+(tn(n)**2)+tn(n))
Yn(n)=Yn1(n+1)
write (*,*) Yn1(n)
enddo
n=n+1
End