Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict types related to acos/asin. #99

Closed
wants to merge 1 commit into from
Closed

Conversation

samth
Copy link
Member

@samth samth commented Jan 16, 2025

@bdeket
Copy link
Contributor

bdeket commented Jan 17, 2025

Hi,
is this the best way to fix this?
since we are basically doing (acos (cos nr)) we know that if nr is ϵ [Real Flonum] the result of cos is going to (/ should) be in the range [-1 .. 1] and the final result should be one of [Real Flonum] too.
Or am I missing something?

@bdeket
Copy link
Contributor

bdeket commented Jan 17, 2025

Managed to find 2 examples that break this:

(let ([A (matrix [[-1.650258747789646e+145 -9.554844718758979e+152]])]
      [B (matrix [[-2.0456892507760957e-130 -1.878691327473384e-122]])])
  (list (matrix-cos-angle A B)
        (matrix-angle A B)))
;; '(1.0000000000000002 0.0+2.1073424255447017e-08i)
(let ([A (matrix [[-1.1137603878341427e-134 1.3937540198551402e-126]])]
      [B (matrix [[1.4964797209265308e+163 -2.0388100696972336e+171]])])
  (list (matrix-cos-angle A B)
        (matrix-angle A B)))
;; '(-1.0000000000000002 3.141592653589793-2.1073424255447017e-08i)

But to me that shows that matrix-cos-angle should be fixed.

@samth
Copy link
Member Author

samth commented Jan 17, 2025

I don't have any idea if this is the best fix, but I don't think the type of acos or asin can be made more precise.

@bdeket bdeket mentioned this pull request Jan 21, 2025
@samth
Copy link
Member Author

samth commented Jan 31, 2025

Merged as part of #100

@samth samth closed this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants