Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site astrovax.UUCP
Path: utzoo!linus!decvax!harpo!eagle!mhuxl!ulysses!princeton!astrovax!draine
From: draine@astrovax.UUCP (Bruce Draine)
Newsgroups: net.lang.f77
Subject: f77 bug
Message-ID: <224@astrovax.UUCP>
Date: Sat, 25-Feb-84 10:19:52 EST
Article-I.D.: astrovax.224
Posted: Sat Feb 25 10:19:52 1984
Date-Received: Sat, 25-Feb-84 04:09:57 EST
Organization: Princeton Univ. Astrophysics
Lines: 58

Subject: Bug in 4.2BSD f77 complex arithmetic

Description:
	Incorrect evaluation of complex arithmetic expressions
	involving library functions CCOS and CSIN.  For example,
	the fortran expression
		A=CCOS(Y)/CSIN(Y)
	with A and Y having been previously "typed" by a
		COMPLEX A,Y
	statement, is not being evaluated correctly for arbitrary
	values of the complex variable Y.
	It is not known to what extent this problem may also be
	endemic to other constructions [e.g., A=CSIN(Y)/CCOS(Y) ].

Repeat-By:
	Compiling and running the following simple program:

C PROGRAM TO TEST APPARENT BUG IN F77 COMPILER
C B.T.DRAINE,PRINCETON UNIV. OBS., 84/2/19
      COMPLEX Y,A,B,C
      Y=(4.601765,-3.839218)
      WRITE(6,9900)Y
 9900 FORMAT(' Y=',1P2E14.7)
C INDIRECT EVALUATION OF COTANGENT(Y)
      A=CCOS(Y)
      B=CSIN(Y)
      C=A/B
      WRITE(6,9969)A,B
 9969 FORMAT(' A=CCOS(Y)=',1P2E14.7,' B=CSIN(Y)=',2E14.7)
      WRITE(6,9970)C
 9970 FORMAT(' C=A/B=',1P2E14.7)
C DIRECT EVALUATION
      C=CCOS(Y)/CSIN(Y)
      WRITE(6,9971)C
 9971 FORMAT(' C=CCOS(Y)/CSIN(Y)=',1P2E14.7)
      STOP
      END

The following output is generated by this program running under
4.2 BSD on our Vax-11/750 with FPA:

***** testf77 compiled with no options 84/2/19 *****
output follows:
 Y= 4.6017652e+00-3.8392179e+00
 A=CCOS(Y)=-2.5673470e+00-2.3091778e+01 B=CSIN(Y)=-2.3113155e+01 2.5649724e+00
 C=A/B= 2.0288443e-04 9.9909759e-01
 C=CCOS(Y)/CSIN(Y)= 1.0000000e+00-1.4885653e-09

***** testf77 compiled with -C option 84/2/19 *****
output follows:
 Y= 4.6017652e+00-3.8392179e+00
 A=CCOS(Y)=-2.5673470e+00-2.3091778e+01 B=CSIN(Y)=-2.3113155e+01 2.5649724e+00
 C=A/B= 2.0288443e-04 9.9909759e-01
 C=CCOS(Y)/CSIN(Y)= 1.0000000e+00-1.4885653e-09

Fix:
	Unknown to me.  Has been reported to ucbvax\!bsd-bugs.