Skip to content

Commit

Permalink
Fix incorrect calculation produced by acotan(num)
Browse files Browse the repository at this point in the history
The num version of the method uses incorrect formula to calculate acotan.
The following identities should hold:
    θ = acotan cotan θ for -π < θ < π
    θ = cotan acotan θ for θ ∈ ℝ

Fix by calculating atan(1/x), result of which is corroborated by the above
identities, WolframAlhpa[^1], and our implementation of acotan for boxed types.

[1] http://www.wolframalpha.com/input/?i=acotan
  • Loading branch information
zoffixznet committed Oct 19, 2016
1 parent 7a456ff commit 8e9fd0a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/Num.pm
Expand Up @@ -493,7 +493,7 @@ multi sub cotan(num $x) returns num {
nqp::div_n(1e0, nqp::tan_n($x));
}
multi sub acotan(num $x) returns num {
nqp::div_n(1e0, nqp::atan_n($x));
nqp::atan_n(nqp::div_n(1e0, $x));
}
multi sub sinh(num $x) returns num {
nqp::sinh_n($x);
Expand Down

0 comments on commit 8e9fd0a

Please sign in to comment.