[git] CMU Common Lisp branch master updated. snapshot-2013-12-a-35-g4e3589d

Raymond Toy rtoy at common-lisp.net
Mon Dec 23 06:41:14 UTC 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".

The branch, master has been updated
       via  4e3589d9d175382fe85b6efe2e3e94ccf598a88e (commit)
       via  1ba45c8177e4a6ef66f7fac3a3870f477a3d03eb (commit)
      from  a9598e606edc4490b8b58aedb4ecdca64b6ffed9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4e3589d9d175382fe85b6efe2e3e94ccf598a88e
Author: Raymond Toy <toy.raymond at gmail.com>
Date:   Sun Dec 22 22:41:03 2013 -0800

    More documentation.
    
    o Derive the value of asin(2), lest we forget again why it is the way
      it is.
    o Use the formulas from the CLHS in the docstrings.

diff --git a/src/code/irrat.lisp b/src/code/irrat.lisp
index 078e56f..ff23a5e 100644
--- a/src/code/irrat.lisp
+++ b/src/code/irrat.lisp
@@ -1916,8 +1916,43 @@ Z may be any number, but the result is always a complex."
 			     (realpart sqrt-z+1))))))))
 
 
+;; What is the value of asin(2)?  Here is a derivation.
+;;
+;; asin(2) = -i*log(i*2+sqrt(-3))
+;;         = -i*log(2*i+sqrt(3)*i)
+;;         = -i*(log(2+sqrt(3)) + i*pi/2)
+;;         = pi/2 - i*log(2+sqrt(3))
+;;
+;; Note that this differs from asin(2+0.0*i) because we support signed
+;; zeroes.
+;;
+;; asin(2+0*i) = -i*log(i*(2+0*i) + sqrt(1-(4+0*i)))
+;;             = -i*log((2*i - 0) + sqrt(-3-0*i))
+;;             = -i*log(-0 + 2*i - sqrt(3)*i)
+;;             = -i*log(-0 + i*(2-sqrt(3)))
+;;             = -i*(log(2-sqrt(3)) + i*pi/2)
+;;             = pi/2 - i*log(2-sqrt(3))
+;;             = pi/2 + i*log(2+sqrt(3))
+;;
+;; The last equation follows because (2-sqrt(3)) = 1/(2+sqrt(3)).
+;; Hence asin(2) /= asin(2+0*i).
+;;
+;; Also
+;;
+;; asin(2-0*i) = -i*log(i*(2-0*i) + sqrt(1-(4-0*i)))
+;;             = -i*log((2*i + 0) + sqrt(-3+0*i))
+;;             = -i*log(0 + 2*i + sqrt(3)*i)
+;;             = -i*log(0 + i*(2+sqrt(3)))
+;;             = -i*(log(2+sqrt(3)) + i*pi/2)
+;;             = pi/2 + i*log(2+sqrt(3))
+;;
+;; Hence asin(2) = asin(2-0.0*i).
+;;
+;; Similar derivations will show that asin(-2) = asin(-2 + 0.0*i) and
+;; asin(-2+0.0*i) is different from asin(-2-0.0*i) because of the
+;; branch cut, of course.
 (defun complex-asin (z)
-  "Compute asin z = asinh(i*z)/i
+  "Compute asin z = -i*log(i*z + sqrt(1-z^2))
 
 Z may be any number, but the result is always a complex."
   (declare (number z))
@@ -1950,7 +1985,7 @@ Z may be any number, but the result is always a complex."
 	     (- (realpart result)))))
 	 
 (defun complex-atan (z)
-  "Compute atan z = atanh (i*z) / i
+  "Compute atan z = (log(1+i*z) - log(1-i*z))/(2*i)
 
 Z may be any number, but the result is always a complex."
   (declare (number z))

commit 1ba45c8177e4a6ef66f7fac3a3870f477a3d03eb
Author: Raymond Toy <toy.raymond at gmail.com>
Date:   Sun Dec 22 22:39:37 2013 -0800

    Use the formulas from the CLHS in the docstrings.

diff --git a/src/code/irrat-dd.lisp b/src/code/irrat-dd.lisp
index 2eabb58..024ec93 100644
--- a/src/code/irrat-dd.lisp
+++ b/src/code/irrat-dd.lisp
@@ -1854,7 +1854,7 @@ Z may be any number, but the result is always a complex."
 
 
 (defun dd-complex-asin (z)
-  _N"Compute asin z = asinh(i*z)/i
+  _N"Compute asin z = -i*log(i*z + sqrt(1-z^2))
 
 Z may be any number, but the result is always a complex."
   (declare (number z))
@@ -1894,7 +1894,7 @@ Z may be any number, but the result is always a complex."
 	     (- (realpart result)))))
 	 
 (defun dd-complex-atan (z)
-  _N"Compute atan z = atanh (i*z) / i
+  _N"Compute atan z = (log(1+i*z) - log(1-i*z))/(2*i)
 
 Z may be any number, but the result is always a complex."
   (declare (number z))

-----------------------------------------------------------------------

Summary of changes:
 src/code/irrat-dd.lisp |    4 ++--
 src/code/irrat.lisp    |   39 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
CMU Common Lisp



More information about the cmucl-cvs mailing list