Master list of constants

279 views
Skip to first unread message

esproff

unread,
Jul 5, 2016, 6:52:52 AM7/5/16
to julia-users
I wasn't able to find a master list of all the constants in Julia.  I'm specifically looking for the ascii name for the Euler-Mascheroni constant γ.  Similar to how the golden ratio is both φ and golden.

Kenta Sato

unread,
Jul 5, 2016, 7:23:08 AM7/5/16
to julia-users
eulergamma is the ASCII alias for γ.

julia> γ
γ = 0.5772156649015...


julia
> eulergamma
γ = 0.5772156649015...


julia
> γ === eulergamma
true


If you are interested in generating the list of constants, you can use this script: https://github.com/isagalaev/highlight.js/blob/d506d1d305e18809b2f5002967a18693780581b0/src/languages/julia.js#L23-L51.

Lyndon White

unread,
Jul 5, 2016, 7:23:47 AM7/5/16
to julia-users
You can use the `names` function to search a module for all constants it defines.
By evaluating the names to get the values, then checking if they are Irrational (formerly known as MathConst?)
By doing this, I conclude that the  ASCII name for the Euler-Mascheroni constant (γ) is eulergamma


 


julia
> for name_sym in names(Base)
       
       value = eval(name_sym)
              if typeof(value)<: Irrational
                            println(name_sym, "\t", value)
              end
       end


catalan catalan
= 0.9159655941772...
e       e
= 2.7182818284590...
eu      e
= 2.7182818284590...
eulergamma      
γ = 0.5772156649015...
golden  
φ = 1.6180339887498...
pi      
π = 3.1415926535897...
γ       γ = 0.5772156649015...
π       π = 3.1415926535897...
φ       φ = 1.6180339887498...



esproff

unread,
Jul 5, 2016, 9:42:27 AM7/5/16
to julia-users
Ok great!  Thanks Kenta and Lyndon for your quick responses!

Stefan Karpinski

unread,
Jul 5, 2016, 7:42:57 PM7/5/16
to Julia Users

mmh

unread,
Jul 5, 2016, 8:44:24 PM7/5/16
to julia-users
On v0.5 this gives:

ERROR: UndefVarError: @MIME not defined
 in eval(::Module, ::Any) at .\boot.jl:234
 in macro expansion; at .\REPL[4]:2 [inlined]
 in anonymous at .\<missing>:?
 in eval(::Module, ::Any) at .\boot.jl:234
 in macro expansion at .\REPL.jl:92 [inlined]
 in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at .\event.jl:46

Waldir Pimenta

unread,
Jul 6, 2016, 8:10:44 AM7/6/16
to julia-users
While we're at it: since all constants in that list are represented by their symbols, with the names serving as aliases, would it be a good idea to define Catalan's constant using the G symbol? If that's too common a character which we wouldn't want to pollute, we could use 𝐺 (mathematical italic capital g, U+1D43A). Current behavior would be unchanged since "catalan" would be added as an alias. Thoughts?
Reply all
Reply to author
Forward
0 new messages