Skip to content

Commit

Permalink
Merge pull request #50 from nsmith5/feature/euler
Browse files Browse the repository at this point in the history
Update to use \euler instead of 'e' as Euler's number
  • Loading branch information
nsmith5 authored Nov 15, 2019
2 parents 7f9bbd0 + 8553830 commit 4ea2166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/mexpr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,17 @@ end


const m_to_jl = Dict(
"%e" => "e",
"%pi" => "π",
"%i" => "im",
"%e" => "",
"%pi" => "π",
"%i" => "im",
"%gamma" => "eulergamma",
"%phi" => "φ",
"inf" => "Inf",
"minf" => "-Inf"
"%phi" => "φ",
"inf" => "Inf",
"minf" => "-Inf"
)

const jl_to_m = Dict(
"e" => "%e",
"eu" => "%e",
"" => "%e",
"pi" => "%pi",
"π" => "%pi",
"γ" => "%gamma",
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ using Test
@test MExpr(:(100x)) == m"100 * x"
@test MExpr(:(-im)) == m"-%i"

# Julia special constant replacement
@test mcall(:(ℯ^(im * π))) == -1
@test mcall(:(e^(im * π))) != -1 # We no longer support 'e' as euler number in Julia >= 1.0

# Calculus tests
@test integrate(:(sin(x)), :x) == :(-cos(x))
@test integrate("exp(-x^2)", "x", "minf", "inf") == "sqrt(%pi)"
Expand Down Expand Up @@ -46,7 +50,7 @@ end
@test logexpand(m"log(x/y)") == m"log(x) - log(y)"
@test trigsimp(m"sin(x)^2 + cos(x)^2") |> parse == 1
@test trigrat(MExpr(:(exp(im*x) + exp(-im*x)))) == MExpr(:(2 * cos(x)))
@test rectform(:(R*e^(im*theta))) == :(im * R * sin(theta) + R * cos(theta))
@test rectform(:(R*^(im*theta))) == :(im * R * sin(theta) + R * cos(theta))
@test polarform(m"a + %i*b") == m"sqrt(a^2 + b^2)*exp(%i * atan2(b, a))"
@test realpart(m"a + %i*b") |> parse == :a
@test imagpart(m"a + %i*b") |> parse == :b
Expand Down

0 comments on commit 4ea2166

Please sign in to comment.