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

^(::AbstractIrrational, ::Integer) should probably behave like ^(::Float64, ::Integer) instead of like ^(::Integer, ::Integer) #55961

Open
nsajko opened this issue Oct 1, 2024 · 0 comments
Labels
maths Mathematical functions

Comments

@nsajko
Copy link
Contributor

nsajko commented Oct 1, 2024

using Test
@testset "`^(::AbstractIrrational, ::Integer)`" begin
    @testset "c: $c" for c  (ℯ, π, MathConstants.γ, MathConstants.φ, MathConstants.catalan)
        let e = -1 
            @test c  (c^e)^e
        end    
    end    
end
Test Summary:                        | Pass  Error  Total  Time
`^(::AbstractIrrational, ::Integer)` |    1      4      5  1.6s
  c: ℯ                               |    1             1  0.0s
  c: π                               |           1      1  1.2s
  c: γ                               |           1      1  0.1s
  c: φ                               |           1      1  0.1s
  c: catalan                         |           1      1  0.1s
ERROR: Some tests did not pass: 1 passed, 0 failed, 4 errored, 0 broken.

Among the Irrational constants, only works as a base for exponentiation here, I guess because that case gets forwarded to exp.

I guess the fix is to define a method something like the following:

^(c::AbstractIrrational, n::Integer) = AbstractFloat(c) ^ n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maths Mathematical functions
Projects
None yet
Development

No branches or pull requests

1 participant