- #1
agsiar
- 2
- 0
Hello. I'm supposed to plot a bifurcation diagram for the logistic map. What I'm trying to do is calculate 1128 iteration of y=a*y*(1-y), scrap the first 1000 and write the last 128 points of data in the LogisticMapDiagram.dat file and then plot that with gnuplot, but the value of y stays in zeroes all the time.
The code:
I've noticed that running a simplified version of the above program yields part of the results that I'm looking for:
I've been told that fortran doesn't like using real numbers in its do statement, but I did another test tabulating sin(x) using x as the counter for the iterator and it worked. The test in question:
I've thought of not using a as the counter, but I can't come up with any way to make it work and I honestly don't know what to do here anymore...
P.S: The indentation got kinda screwed after CP-ing the code...
EDIT:
Nope, changing the counter from a real number to an integer and make the value of a vary within that do makes no difference... Code:
The code:
program BifurcationDiagram
implicit none
real y, a
integer i
open (unit=2, file="LogisticMapDiagram.dat")
write (2,*) "# a"," y"
y=0.4
a=0.0
print *, "beginning do"
do i=1,1128,1
do a=0.,4.,0.01
y=a*y*(1-y)
if (i .ge. 1001) then
write (2,*) a, y
end if
end do
end do
print *, "i'm done"
end program
implicit none
real y, a
integer i
open (unit=2, file="LogisticMapDiagram.dat")
write (2,*) "# a"," y"
y=0.4
a=0.0
print *, "beginning do"
do i=1,1128,1
do a=0.,4.,0.01
y=a*y*(1-y)
if (i .ge. 1001) then
write (2,*) a, y
end if
end do
end do
print *, "i'm done"
end program
I've noticed that running a simplified version of the above program yields part of the results that I'm looking for:
program Test
real y, a
y = 0.4
a=3.7
open (unit=2, file="Test.dat")
do i=1,1128,1
y=a*y*(1-y)
if (i .ge. 1001) then
write (2,*) a, y
end if
end do
print*, "i'm done"
end program
I've also noticed that if I don't specify a value of a and change do i=1,1128,1 for do a=0.,4.,0.01 in the immediately above code, I go back to getting nothing but zeroes for y. Thing is, I really do need to sweep the value of a, preferably in steps of 0.001 instead of steps of 0.01.real y, a
y = 0.4
a=3.7
open (unit=2, file="Test.dat")
do i=1,1128,1
y=a*y*(1-y)
if (i .ge. 1001) then
write (2,*) a, y
end if
end do
print*, "i'm done"
end program
I've been told that fortran doesn't like using real numbers in its do statement, but I did another test tabulating sin(x) using x as the counter for the iterator and it worked. The test in question:
program TabulatingSine
real x
open (unit=2, file="SenoTabulado.dat")
write (2,10) "#x","seno(x)"
10 format (a,4x,a)
do x=0.,6.28318530718,0.001
write (2,20) x, sin(x)
20 format (f10.5,4x,f10.5)
end do
print *, "the program did something"
print *, "bye."
end program
real x
open (unit=2, file="SenoTabulado.dat")
write (2,10) "#x","seno(x)"
10 format (a,4x,a)
do x=0.,6.28318530718,0.001
write (2,20) x, sin(x)
20 format (f10.5,4x,f10.5)
end do
print *, "the program did something"
print *, "bye."
end program
I've thought of not using a as the counter, but I can't come up with any way to make it work and I honestly don't know what to do here anymore...
P.S: The indentation got kinda screwed after CP-ing the code...
EDIT:
Nope, changing the counter from a real number to an integer and make the value of a vary within that do makes no difference... Code:
program DiagramaBifurcacion
implicit none
real y, a
integer i, j
!double precision y, a
open (unit=2, file="MapaLogisticoDiagrama.dat")
write (2,*) "# a"," y"
y=0.4
a=-0.01
print *, "beginning do"
do j=0,400,1
a=a+0.01
do i=1,1128,1
y=a*y*(1-y)
if (i .ge. 1001) then
write (2,*) i, a, y
end if
end do
end do
print *, "i'm done"
end program
Now I'm truly at a complete loss of what to do...implicit none
real y, a
integer i, j
!double precision y, a
open (unit=2, file="MapaLogisticoDiagrama.dat")
write (2,*) "# a"," y"
y=0.4
a=-0.01
print *, "beginning do"
do j=0,400,1
a=a+0.01
do i=1,1128,1
y=a*y*(1-y)
if (i .ge. 1001) then
write (2,*) i, a, y
end if
end do
end do
print *, "i'm done"
end program
Last edited: