How can I get the symbolic real or imaginary part of a `Sym`

expression? `real`

gives a BigFloat instead:

```
julia> sqrt(Sym(5))+im
√5 + ⅈ
julia> sqrt(Sym(5))+im |> real
2.236067977499789696409173668731276235440618359611525724270897245410520925637785
```

How can I get the symbolic real or imaginary part of a `Sym`

expression? `real`

gives a BigFloat instead:

```
julia> sqrt(Sym(5))+im
√5 + ⅈ
julia> sqrt(Sym(5))+im |> real
2.236067977499789696409173668731276235440618359611525724270897245410520925637785
```

There is `sympy.re`

(and `sympy.im`

) to return the `a`

and `b`

of `a+b im`

. But it seems the definitions of `real`

and `imag`

should be changed, as they are returning numeric values, not symbolic values. (`real` and `imag` · Issue #442 · JuliaPy/SymPy.jl · GitHub)

1 Like