Re: Order of parameters in early SIGN(A,B) function?



"Terence" <tbwright@xxxxxxxxx> wrote in message
news:d93f0a51-fcc5-44ee-bd01-6a0bc143477f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I am working on some old (1966) Fortran programs, converted from
Fortran II.
I have just met this use of the SIGN function in a matrix rotation
situation (Jacobi).
The comment says the following lines compute a Tangent, then a Sine
and Cosine.

As I understand the modern use of SIGN(A,B), it transfers the sign of
the B parameter to the A parameter. Yet here, the A parameter is
always of absolute magnitude 2.0 and the related sine and cosine
therefore also fixed.
But Cosine is calculated from the Tangent and the Sine will be +/-
twice the Tangent.

Is it possible that the huge first line computation of "B" computes
only a sign, to be tranferred to a magnitude of 2.0 as the A value?
Or were the SIGN parameters of Fortran II interchanged from the the
current understanding?
(I have completed all the D,M,S and most X series of the 56 BMD
programs; this is an outstanding 6M after which I have only 14 more,
the T(2),R(4) and V(8) series to rewrite).

C COMPUTE TANGENT, SINE AND COSINE,H(I,I),H
(J,J)
150 TANG=SIGN(2.0,(H(IPIV,IPIV)-H(JPIV,JPIV)))*H(IPIV,JPIV)/
1(ABS(H(IPIV,IPIV)-H(JPIV,JPIV))+SQRT((H(IPIV,IPIV)-H(JPIV,JPIV))
**2
+4.0*H(IPIV,JPIV)**2))
COSINE=1.0/SQRT(1.0+TANG**2)
SINE=TANG*COSINE
C
HII=H(IPIV,IPIV)
H(IPIV,IPIV)=
1 COSINE**2*(HII+TANG*(2.0*H(IPIV,JPIV)+TANG*H(JPIV,JPIV)))
H(JPIV,JPIV)=
1 COSINE**2*(H(JPIV,JPIV)-TANG*(2.0*H(IPIV,JPIV)-TANG*HII))
H(IPIV,JPIV)=0.0

I think you're miscounting parentheses.

150 TANG=SIGN(2.0,(H(IPIV,IPIV)-H(JPIV,JPIV)))*H(IPIV,JPIV)/
^ ^

The perentheses surrounding the arguments to the SIGN function
are as indicated above. It looks like the whole expression is
intended to solve the quadratic eqaution

A*x**2+B*x+C == 0

with

A = H(IPIV,JPIV)
B = H(IPIV,IPIV)-H(JPIV,JPIV)
C = -H(IPIV,JPIV)

The solution is

x = (-B+-sqrt(B**2-4*A*C))/(2*A) = 2*(-C)/(B+-sqrt(B**2-4*A*C))

The complicated expression picks the smaller root in absolute
value.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


.



Relevant Pages

  • Re: Maxwells Equations
    ... > which simulated altitude with a voltage. ... The first derivative of the sine function is the cosine function. ... Tangent is just a ratio, ...
    (sci.physics.relativity)
  • Re: Maxwells Equations
    ... > which simulated altitude with a voltage. ... The first derivative of the sine function is the cosine function. ... Tangent is just a ratio, ...
    (sci.physics.relativity)
  • Re: double pointers
    ... double sincostan(double angle, double *pcosine, double *ptangent) ... double cosine = cos; ... double tangent = tan; ... return sine; ...
    (comp.programming)
  • Re: trig. formula Question
    ... >> Inverted Cosine ... >> Inverted Sine ... >> Inverted Tangent ...
    (sci.math)
  • Order of parameters in early SIGN(A,B) function?
    ... I am working on some old Fortran programs, ... The comment says the following lines compute a Tangent, then a Sine ...
    (comp.lang.fortran)