-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move mathematical constants to Base.MathConstants (#23427)
- only export pi, π and ℯ from Base - remove eu as alias for ℯ - add \euler as tab completion for ℯ
- Loading branch information
1 parent
9d6c9bd
commit 8f6f5aa
Showing
20 changed files
with
157 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,10 +186,7 @@ export | |
NaN64, | ||
im, | ||
π, pi, | ||
e, eu, | ||
γ, eulergamma, | ||
catalan, | ||
φ, golden, | ||
ℯ, | ||
I, | ||
|
||
# Operators | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
""" | ||
Base.MathConstants | ||
Module containing the mathematical constants. | ||
See [`π`](@ref), [`ℯ`](@ref), [`γ`](@ref), [`φ`](@ref) and [`catalan`](@ref). | ||
""" | ||
module MathConstants | ||
|
||
export π, pi, ℯ, e, γ, eulergamma, catalan, φ, golden | ||
|
||
Base.@irrational π 3.14159265358979323846 pi | ||
Base.@irrational ℯ 2.71828182845904523536 exp(big(1)) | ||
Base.@irrational γ 0.57721566490153286061 euler | ||
Base.@irrational φ 1.61803398874989484820 (1+sqrt(big(5)))/2 | ||
Base.@irrational catalan 0.91596559417721901505 catalan | ||
|
||
# aliases | ||
""" | ||
π | ||
pi | ||
The constant pi. | ||
```jldoctest | ||
julia> pi | ||
π = 3.1415926535897... | ||
``` | ||
""" | ||
π, const pi = π | ||
|
||
""" | ||
ℯ | ||
e | ||
The constant ℯ. | ||
```jldoctest | ||
julia> ℯ | ||
ℯ = 2.7182818284590... | ||
``` | ||
""" | ||
ℯ, const e = ℯ | ||
|
||
""" | ||
γ | ||
eulergamma | ||
Euler's constant. | ||
```jldoctest | ||
julia> MathConstants.eulergamma | ||
γ = 0.5772156649015... | ||
``` | ||
""" | ||
γ, const eulergamma = γ | ||
|
||
""" | ||
φ | ||
golden | ||
The golden ratio. | ||
```jldoctest | ||
julia> MathConstants.golden | ||
φ = 1.6180339887498... | ||
``` | ||
""" | ||
φ, const golden = φ | ||
|
||
""" | ||
catalan | ||
Catalan's constant. | ||
```jldoctest | ||
julia> MathConstants.catalan | ||
catalan = 0.9159655941772... | ||
``` | ||
""" | ||
catalan | ||
|
||
# loop over types to prevent ambiguities for ^(::Number, x) | ||
for T in (Irrational, Rational, Integer, Number) | ||
Base.:^(::Irrational{:ℯ}, x::T) = exp(x) | ||
end | ||
|
||
Base.log(::Irrational{:ℯ}) = 1 # use 1 to correctly promote expressions like log(x)/log(ℯ) | ||
Base.log(::Irrational{:ℯ}, x::Number) = log(x) | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.