McCracken's Fortran 77 book

19 views
Skip to first unread message

Beliavsky

unread,
Jan 8, 2011, 4:09:47 PM1/8/11
to Fortran
Although I program in Fortran 95 using g95 and gfortran, I think some
of F77 books are interesting. One that I like is "Computing for
Engineers and Scientists with Fortran 77", by Daniel McCracken. Since
the group is so quiet, I wonder if there would be interest in working
through the problems in this book. Here is question 9(a) from Chapter
1, p81:

"In each of the following you are given an infinite series that
converges to a value involving pi. For each, if you compute the sum of
the series through the term shown in parenthesis, you will get an
approximation to the value of the series that is accurate to about six
decimal places. For each, write a pseudocode and a program to carry
out the summation; then print that value along with the value given by
the formula."

Here is my program.

program xseries
! Riemann zeta function
implicit none
integer, parameter :: rk=kind(1.0d0)
real, parameter :: pi=3.141592653589793238462643_rk
integer :: i,n,pow
real(kind=rk) :: term,xsum
pow = 6 ! "s" argument
n = 11
xsum = 0.0_rk
do i=1,n ! solution using a loop
term = 1/(dble(i)**pow)
xsum = xsum + term
print "(i6,2(1x,f14.10))",i,term,xsum
end do
print*,sum(1/(dble([(i,i=1,n)]))**pow) ! F90 one-liner
if (pow == 6) print*,"True value: ",(pi**6)/945
end program xseries

Here is the output -- it works.

1 1.0000000000 1.0000000000
2 0.0156250000 1.0156250000
3 0.0013717421 1.0169967421
4 0.0002441406 1.0172408827
5 0.0000640000 1.0173048827
6 0.0000214335 1.0173263162
7 0.0000084999 1.0173348161
8 0.0000038147 1.0173386308
9 0.0000018817 1.0173405124
10 0.0000010000 1.0173415124
11 0.0000005645 1.0173420769
1.0173420769153614
True value: 1.0173433

Beliavsky

unread,
Jan 8, 2011, 4:12:23 PM1/8/11
to Fortran
I forgot to list the series to be computed. It is

1/1^6 + 1/2^6 + 1/3^6 ... = (pi^6)/945

One is supposed to use 11 terms.

Terence

unread,
Feb 9, 2011, 4:14:40 AM2/9/11
to Fortran
I have both the McCracken book and "Dr Riemann's Zeroes" by Karl
Sabbagh.
As an aside, as well as the distribution of primes, the zeta function
has been shown to correlate with the sound frequencies of harmonics
surviving from striking a glass sphere (impulse input, frequency modes
output).
My aside aside, I am curious about a highly convergent generator for
pi/4, based on an obscure geometrical theorem of the 1800's that
equates pi/4 as a series of terms with factors based on a root of 5
(third, fifth?), but cannot locate it.
I remember the theorem used a sequence of 5 adjacent acute triangles,
each but first and last sharing two sides of its neighbours. Sad to
say, I suspect it is in a book in my large librarary, most on
Mathematics or Physics....
Reply all
Reply to author
Forward
0 new messages