Raymond Toy pushed to branch rtoy-issue-78-unneded-code-code-in-complex-acos at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/code/irrat.lisp
    ... ... @@ -1726,6 +1726,46 @@ Z may be any number, but the result is always a complex."
    1726 1726
     		   (asinh (imagpart (* (conjugate sqrt-1+z)
    
    1727 1727
     				       sqrt-1-z))))))))
    
    1728 1728
     
    
    1729
    +;; acosh(z) = 2*log(sqrt((x+1)/2) + sqrt((x-1)/2))
    
    1730
    +;;
    
    1731
    +;; For z = x, 0 <= x < 1
    
    1732
    +;;  acosh(z) = 2*log(sqrt((x+1)/2) + sqrt((x-1)/2))
    
    1733
    +;;           = 2*log(sqrt((x+1)/2) + i*sqrt((1-x)/2))
    
    1734
    +;;           = 2*(log(1) + i*arg(sqrt((x+1)/2) + i*sqrt((1-x)/2)))
    
    1735
    +;;           = 2*i*atan(sqrt((1-x)/2), sqrt((x+1)/2))
    
    1736
    +;;           = 2*i*atan(sqrt((1-x)/(1+x)))
    
    1737
    +;;
    
    1738
    +;; For z = -x, x > 1
    
    1739
    +;;  acosh(z) = 2*log(sqrt((1-x)/2) + sqrt((-x-1)/2))
    
    1740
    +;;           = 2*log((i*sqrt((x-1)/2) + 0 + i*sqrt((1+x)/2)) + 0)
    
    1741
    +;;           = 2*log(i*(sqrt((x-1)/2) + sqrt((1+x)/2)) + 0)
    
    1742
    +;;           = 2*(log(sqrt((x-1)/2) + sqrt((1+x)/2)) + i*arg(sqrt((x-1)/2) + sqrt((1+x)/2)) + 0)
    
    1743
    +;;           = 2*(log(sqrt((x-1)/2) + sqrt((1+x)/2)) + i*pi/2)
    
    1744
    +;;           = 2*log(x+sqrt(x+1)*sqrt(x-1)) + i*pi
    
    1745
    +;;
    
    1746
    +;; For z = x + i0, 0 <= x < 1
    
    1747
    +;;  acosh(z) = 2*log(sqrt((1+x)/2+i0) + sqrt((x-1)/2+i0))
    
    1748
    +;;           = 2*log(sqrt((1+x)/2)+i0 + i*sqrt((1-x)/2) + 0)
    
    1749
    +;;           = 2*log(sqrt((1+x)/2) + i*sqrt((1-x)/2))
    
    1750
    +;;           = 2*(log(1) + i*arg(sqrt((1+x)/2) + i*sqrt((1-x)/2))
    
    1751
    +;;           = 0 + 2*i*atan(sqrt((1-x)/2)/sqrt((1+x)/2)) + 
    
    1752
    +;;           = 0 + 2*i*atan(sqrt((1-x)/(1+x))
    
    1753
    +;;
    
    1754
    +;; This is the same value we got for acosh(x), 0 <= x < 1.  Hence,
    
    1755
    +;; acosh is continuous with quadrant I on the branch cut for 0 <= x <
    
    1756
    +;; 1.
    
    1757
    +;;
    
    1758
    +;; Finally, for z = -x + i0, x > 1
    
    1759
    +;;  acosh(z) = 2*log(sqrt((1-x)/2+i0) + sqrt((-x-1)/2+i0))
    
    1760
    +;;           = 2*log(i*sqrt((x-1)/2) + 0 + i*sqrt((1+x)/2 + i0))
    
    1761
    +;;           = 2*log(i*(sqrt((x-1)/2) + sqrt((1+x)/2)) + 0)
    
    1762
    +;;           = 2*(log(sqrt((x-1)/2) + sqrt((1+x)/2)) + i*arg(0, (sqrt((x-1)/2) + sqrt((1+x)/2)))
    
    1763
    +;;           = 2*(log(sqrt((x-1)/2) + sqrt((1+x)/2)) + i*pi/2)
    
    1764
    +;;           = 2*log(sqrt((x-1)/2) + sqrt((1+x)/2)) + i*pi
    
    1765
    +;;
    
    1766
    +;; We see that this is the same expression for acosh(z), z < -1.
    
    1767
    +;; Hence, acosh(z) is continuous with quadrant II on the branch cut x
    
    1768
    +;; < -1.
    
    1729 1769
     (defun complex-acosh (z)
    
    1730 1770
       "Compute acosh z = 2 * log(sqrt((z+1)/2) + sqrt((z-1)/2))
    
    1731 1771