# Symbolics.jl simplify exp(0) to 1

**URL:** https://discourse.julialang.org/t/symbolics-jl-simplify-exp-0-to-1/135970
**Category:** New to Julia
**Tags:** symbolics
**Created:** [March 2, 2026, 6:32pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplify-exp-0-to-1/135970 "2026-03-02T18:32:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jhai](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@jhai](https://discourse.julialang.org/u/jhai)
#### Post date: [March 2, 2026, 6:32pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplify-exp-0-to-1/135970/1 "2026-03-02T18:32:41Z")

</div>

I’m trying to check a system of linear differential equations using symbolic variables:  
X'(t)=R(\alpha)X(t)  
This is my code

```julia-auto
using Symbolics
using SymbolicUtils
using LinearAlgebra

@variables α t

R = [cos(α) -sin(α); sin(α) cos(α)]

X = [im*exp(exp(α*im)*t) -im*exp(exp(-α*im)*t);
     exp(exp(α*im)*t) exp(exp(-α*im)*t)]

# Check the fundamental matrix
Dt = Differential(t)
dX = Dt.(X)

dX = expand_derivatives.(dX)

dX = expand.(dX)

H = simplify.(dX.-R*X)

display(H)

H = substitute.(H, (Dict(exp(0) => 1),))

display(H)

```

However the terms in the final output always contain things like “exp(0)”, eventhough the solution should be correct:

```julia-auto
2×2 Matrix{Complex{Num}}:
 0 cos(-α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) - cos(α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) + (sin(-α) + sin(α))*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) + im*(-cos(-α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) + cos(α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) + sin(t*exp(0)*sin(-α))*(sin(-α) + sin(α))*exp(t*exp(0)*cos(-α)))
 0 cos(-α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) - cos(α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) - sin(t*exp(0)*sin(-α))*(sin(-α) + sin(α))*exp(t*exp(0)*cos(-α)) + im*(cos(-α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) - cos(α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) + (sin(-α) + sin(α))*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)))

```

For the past hour I’ve tried every combination of “substitute.”, “expand.”, “simplify.” , but it doesn’t even get rid of the exp(0).

It would also be nice to have things like \cos(-\alpha) = \cos(\alpha) and \sin(-\alpha)=-\sin(\alpha).

Thanks for any help!

---

<div class="post-metadata">

### Author: ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)
#### Post date: [March 2, 2026, 6:47pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplify-exp-0-to-1/135970/2 "2026-03-02T18:47:55Z")

</div>

It would be nice to have such simple rules available by default. You could define the rules yourself.

For example:

```julia
rules = RuleSet([
    @rule(exp(0) => 1),
    @rule(sin(-(~x)) => -(sin(~x))),
    @rule(cos(-(~x)) => cos(~x))
])

H2 = map(H) do h
    re = simplify(real(h), rewriter=rules)
    im_part = simplify(imag(h), rewriter=rules)
    re + im * im_part
end

```

Will yield

```julia
2×2 Matrix{Complex{Num}}:
 0 cos(-α)*sin(t*sin(-α))*exp(t*cos(-α)) - cos(α)*sin(t*sin(-α))*exp(t*cos(-α)) + (sin(-α) + sin(α))*cos(t*sin(-α))*exp(t*cos(-α)) + im*(-cos(-α)*cos(t*sin(-α))*exp(t*cos(-α)) + cos(α)*cos(t*sin(-α))*exp(t*cos(-α)) + (sin(-α) + sin(α))*sin(t*sin(-α))*exp(t*cos(-α)))
 0 cos(-α)*cos(t*sin(-α))*exp(t*cos(-α)) - cos(α)*cos(t*sin(-α))*exp(t*cos(-α)) - (sin(-α) + sin(α))*sin(t*sin(-α))*exp(t*cos(-α)) + im*(cos(-α)*sin(t*sin(-α))*exp(t*cos(-α)) - cos(α)*sin(t*sin(-α))*exp(t*cos(-α)) + (sin(-α) + sin(α))*cos(t*sin(-α))*exp(t*cos(-α)))

```

I’m not sure why the `cos(-α)` is not taking…

edit:

This works:

```julia
rules = RuleSet([
    @rule(exp(0) => 1),
    @rule(sin((-1) * (~x)) => -(sin(~x))),
    @rule(cos((-1) * (~x)) => cos(~x)),
])

```

that yields

```julia
2×2 Matrix{Complex{Num}}:
 0 0
 0 0

```
