Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cmucl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Carl Shapiro
cmucl
Commits
bf112732
Commit
bf112732
authored
11 years ago
by
Raymond Toy
Browse files
Options
Downloads
Patches
Plain Diff
Document the value of atan better. The CLHS is confusing.
Clean up comments for asin too.
parent
196e1482
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tests/trig.lisp
+34
-5
34 additions, 5 deletions
src/tests/trig.lisp
with
34 additions
and
5 deletions
src/tests/trig.lisp
+
34
−
5
View file @
bf112732
...
...
@@ -482,14 +482,16 @@
(
complex
0
z
)))
;; asin(x) = -i*log(i*x + sqrt(1-x^2))
(
defun
asin-def
(
z
)
(
-
(
i*z
(
log
(
+
(
i*z
z
)
(
sqrt
(
1-z
(
*
z
z
))))))))
;; asin branch cut is the real axis |x| > 1. For x < -1, it is
;;
;; The branch cut is the real axis |x| > 1. For x < -1, it is
;; continuous with quadrant II; for x > 1, continuous with quadrant
;; IV.
;;
(
defun
asin-def
(
z
)
(
-
(
i*z
(
log
(
+
(
i*z
z
)
(
sqrt
(
1-z
(
*
z
z
))))))))
(
define-test
branch-cut.asin
(
:tag
:asin
:branch-cuts
)
;; Test for x < -1, which is continuous with Quadrant II. Compute
...
...
@@ -566,6 +568,33 @@
;; atan(z) = (log(1+i*z) - log(1-i*z))/(2*i)
;; = -i/2*(log(1+i*z) - log(1-i*z))
;;
;; WARNING: The CLHS is a bit confused here. Two definitions of atan
;; are given in the CLHS
;; http://www.lispworks.com/documentation/HyperSpec/Body/f_asin_.htm
;; and they are not consistent. Plus, there is a typo in the second
;; definition. (Missing parens.)
;;
;; For clarification, we turn to
;; http://www.lispworks.com/documentation/HyperSpec/Issues/iss069_w.htm,
;; which recommends using the second formula and also puts in the
;; parentheses in the correct places.
;;
;; BUT, this is further confused by the example that atan(0+2*i) is
;; 1.57-0.549*i for the proposed formula but -1.57+0.549*i under the
;; current formula.
;;
;;
;; I think the inconsistency is that the results are derived without
;; signed zeroes. But we have signed zeroes, so let us derive the
;; actual value of atan(0+2*i) using the (second) formula.
;;
;; atan(0+2*i) = (log(1+i*(0+2*i)) - log(1-i*(0+2*i)))/(2*i)
;; = (log(1+(-2+0*i)) - log(1-(-2+0*i)))/(2*i)
;; = (log(-1-0*i) - log(3-0*i))/(2*i)
;; = ((log(1) - pi*i) - (log(3) - 0*i))/(2*i)
;; = (-log(3) - pi*i)/(2*i)
;; = -pi/2 + log(3)/2*i
;;
;; The branch cut is the imaginary axis, |y| > 1. For y < -1, atan is
;; continuous with Quadrant IV; for y > 1, Quadrant II.
(
defun
atan-def
(
z
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment