diff --git a/Project.toml b/Project.toml index 1f55c92..389876d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "IrrationalConstants" uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" authors = ["JuliaMath"] -version = "0.1.0" +version = "0.1.1" [compat] julia = "1" diff --git a/README.md b/README.md index bd0975f..ce602e4 100644 --- a/README.md +++ b/README.md @@ -7,27 +7,36 @@ This package defines the following irrational constants: ```julia -twoπ # 2π -fourπ # 4π -halfπ # π / 2 -quartπ # π / 4 -invπ # 1 / π -twoinvπ # 2 / π -fourinvπ # 4 / π -inv2π # 1 / (2π) -inv4π # 1 / (4π) -sqrt2 # √2 -sqrt3 # √3 -sqrtπ # √π -sqrt2π # √2π -sqrt4π # √4π -sqrthalfπ # √(π / 2) -invsqrt2 # 1 / √2 -invsqrt2π # 1 / √2π -loghalf # log(1 / 2) -logtwo # log(2) -logπ # log(π) -log2π # log(2π) -log4π # log(4π) +twoπ # 2π +fourπ # 4π +halfπ # π / 2 +quartπ # π / 4 +invπ # 1 / π +twoinvπ # 2 / π +fourinvπ # 4 / π +inv2π # 1 / (2π) +inv4π # 1 / (4π) +sqrt2 # √2 +sqrt3 # √3 +sqrtπ # √π +sqrt2π # √2π +sqrt4π # √4π +sqrthalfπ # √(π / 2) +sqrtquartπ # √(π / 4) +invsqrt2 # 1 / √2 +invsqrt3 # 1 / √3 +invsqrtπ # 1 / √π +invsqrt2π # 1 / √2π +invsqrt4π # 1 / √4π +invsqrthalfπ # 1 / √(π / 2) +invsqrtquartπ # 1 / √(π / 4) +loghalf # log(1 / 2) +logtwo # log(2) +log3 # log(3) +logπ # log(π) +log2π # log(2π) +log4π # log(4π) +loghalfπ # log(π / 2) +logquartπ # log(π / 4) ``` diff --git a/src/IrrationalConstants.jl b/src/IrrationalConstants.jl index 0e67e43..64a05bc 100644 --- a/src/IrrationalConstants.jl +++ b/src/IrrationalConstants.jl @@ -3,28 +3,37 @@ module IrrationalConstants using Base: @irrational export - twoπ, # 2π - fourπ, # 4π - halfπ, # π / 2 - quartπ, # π / 4 - invπ, # 1 / π - twoinvπ, # 2 / π - fourinvπ, # 4 / π - inv2π, # 1 / (2π) - inv4π, # 1 / (4π) - sqrt2, # √2 - sqrt3, # √3 - sqrtπ, # √π - sqrt2π, # √2π - sqrt4π, # √4π - sqrthalfπ, # √(π / 2) - invsqrt2, # 1 / √2 - invsqrt2π, # 1 / √2π - loghalf, # log(1 / 2) - logtwo, # log(2) - logπ, # log(π) - log2π, # log(2π) - log4π # log(4π) + twoπ, # 2π + fourπ, # 4π + halfπ, # π / 2 + quartπ, # π / 4 + invπ, # 1 / π + twoinvπ, # 2 / π + fourinvπ, # 4 / π + inv2π, # 1 / (2π) + inv4π, # 1 / (4π) + sqrt2, # √2 + sqrt3, # √3 + sqrtπ, # √π + sqrt2π, # √2π + sqrt4π, # √4π + sqrthalfπ, # √(π / 2) + sqrtquartπ, # √(π / 4) + invsqrt2, # 1 / √2 + invsqrt3, # 1 / √3 + invsqrtπ, # 1 / √π + invsqrt2π, # 1 / √2π + invsqrt4π, # 1 / √4π + invsqrthalfπ, # 1 / √(π / 2) + invsqrtquartπ, # 1 / √(π / 4) + loghalf, # log(1 / 2) + logtwo, # log(2) + log3, # log(3) + logπ, # log(π) + log2π, # log(2π) + log4π, # log(4π) + loghalfπ, # log(π / 2) + logquartπ # log(π / 4) include("stats.jl") diff --git a/src/stats.jl b/src/stats.jl index 05fc5bb..bfbb523 100644 --- a/src/stats.jl +++ b/src/stats.jl @@ -11,18 +11,27 @@ @irrational inv2π 0.159154943091895335769 inv(2 * big(π)) @irrational inv4π 0.079577471545947667884 inv(4 * big(π)) -@irrational sqrt2 1.4142135623730950488 sqrt(big(2)) -@irrational sqrt3 1.7320508075688772935 sqrt(big(3)) -@irrational sqrtπ 1.7724538509055160273 sqrt(big(π)) -@irrational sqrt2π 2.5066282746310005024 sqrt(2 * big(π)) -@irrational sqrt4π 3.5449077018110320546 sqrt(4 * big(π)) -@irrational sqrthalfπ 1.2533141373155002512 sqrt(big(π) / 2) +@irrational sqrt2 1.4142135623730950488 sqrt(big(2)) +@irrational sqrt3 1.7320508075688772935 sqrt(big(3)) +@irrational sqrtπ 1.7724538509055160273 sqrt(big(π)) +@irrational sqrt2π 2.5066282746310005024 sqrt(2 * big(π)) +@irrational sqrt4π 3.5449077018110320546 sqrt(4 * big(π)) +@irrational sqrthalfπ 1.2533141373155002512 sqrt(big(π) / 2) +@irrational sqrtquartπ 0.8862269254527580136 sqrt(big(π) / 4) -@irrational invsqrt2 0.7071067811865475244 inv(sqrt(big(2))) -@irrational invsqrt2π 0.3989422804014326779 inv(sqrt(2 * big(π))) +@irrational invsqrt2 0.7071067811865475244 inv(sqrt(big(2))) +@irrational invsqrt3 0.5773502691896257645 inv(sqrt(big(3))) +@irrational invsqrtπ 0.5641895835477562869 inv(sqrt(big(π))) +@irrational invsqrt2π 0.3989422804014326779 inv(sqrt(2 * big(π))) +@irrational invsqrt4π 0.2820947917738781435 inv(sqrt(4 * big(π))) +@irrational invsqrthalfπ 0.7978845608028653559 inv(sqrt(big(π) / 2)) +@irrational invsqrtquartπ 1.1283791670955125739 inv(sqrt(big(π) / 4)) -@irrational loghalf -0.6931471805599453094 log(inv(big(2))) -@irrational logtwo 0.6931471805599453094 log(big(2)) -@irrational logπ 1.1447298858494001741 log(big(π)) -@irrational log2π 1.8378770664093454836 log(2 * big(π)) -@irrational log4π 2.5310242469692907930 log(4 * big(π)) +@irrational loghalf -0.6931471805599453094 log(inv(big(2))) +@irrational logtwo 0.6931471805599453094 log(big(2)) +@irrational log3 1.0986122886681096914 log(big(3)) +@irrational logπ 1.1447298858494001741 log(big(π)) +@irrational log2π 1.8378770664093454836 log(2 * big(π)) +@irrational log4π 2.5310242469692907930 log(4 * big(π)) +@irrational loghalfπ 0.4515827052894548647 log(big(π) / 2) +@irrational logquartπ -0.2415644752704904447 log(big(π) / 4) diff --git a/test/runtests.jl b/test/runtests.jl index 35e6fbf..c2c2d44 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -26,15 +26,24 @@ end @test isapprox(sqrt(2pi), sqrt2π) @test isapprox(sqrt(4pi), sqrt4π) @test isapprox(sqrt(pi/2), sqrthalfπ) + @test isapprox(sqrt(pi/4), sqrtquartπ) @test isapprox(sqrt(1/2), invsqrt2) + @test isapprox(sqrt(1/3), invsqrt3) + @test isapprox(sqrt(1/pi), invsqrtπ) @test isapprox(sqrt(1/(2pi)), invsqrt2π) + @test isapprox(sqrt(1/(4pi)), invsqrt4π) + @test isapprox(sqrt(2/pi), invsqrthalfπ) + @test isapprox(sqrt(4/pi), invsqrtquartπ) end @testset "log" begin @test isapprox(log(1/2), loghalf) @test isapprox(log(2), logtwo) + @test isapprox(log(3), log3) @test isapprox(log(pi), logπ) @test isapprox(log(2pi), log2π) @test isapprox(log(4pi), log4π) + @test isapprox(log(pi/2), loghalfπ) + @test isapprox(log(pi/4), logquartπ) end