Symbolics.jl
Symbolics.jl copied to clipboard
Derivative of `exp(im*x)` fails
MWE
using Symbolics
Symbolics.derivative(exp(im*x),x)
gives
ERROR: MethodError: no method matching decompose(::Num)
Closest candidates are:
decompose(::Integer) at float.jl:555
decompose(::Float16) at float.jl:557
decompose(::Float32) at float.jl:568
...
Stacktrace:
[1] isfinite(x::Num)
@ Base ./float.jl:453
[2] exp(z::Complex{Num})
@ Base ./complex.jl:642
[3] top-level scope
@ REPL[10]:1
Is this just a matter of defining a isfinite for Num?
Edit: with
Base.isfinite(::Num) = true
it gives 0.
I'm using Symbolics v0.1.25
┆Issue is synchronized with this Trello card by Unito
It does not fail at all, you could be more explicit. If you add @syms x::Real before, this would be the output
julia> Symbolics.derivative(exp(im*x),x)
(0 + 1im)*exp((im)*x)
I defined x using the @variables macro. Using @syms like you pointed out works. Thank you.
What is the difference between @variables and @syms (and when should I use each)?
How to implement complex expand and use it to simplify?
Like exp(im*x)=cos(x)+im*sin(x)
How to implement complex expand and use it to simplify? Like
exp(im*x)=cos(x)+im*sin(x)
also my question https://github.com/JuliaSymbolics/Symbolics.jl/issues/591