The type exists already:
julia> complex(pi, pi) |> typeof
Complex{Irrational{:π}}
but the point is that the parameter of Complex{T}
is the type of both the real and the imaginary parts, so the only way to build a Complex{Irrational{...}}
is to do complex(x, x)
with x isa Irrational
.
If one wants to have complex(pi)
with the highest precision possible, complex(big(pi))
is the only solution currently.
For more information see:
opened 08:02PM - 28 Mar 17 UTC
closed 05:30PM - 01 Oct 17 UTC
maths
complex
A `Complex{Irrational}` is allowed (e.g., `Complex(pi, pi)`), but there are a fe… w functions that currently don't work with this type (e.g., `exp`, `exp2`, `exp10`; `exp` can be easily fixed if #21203 is merged, the other two functions can be fixed as part of the fix to #21200).
Should this type be kept (and non-working functions fixed) or automatically converted to, say, `Complex{Float64}`? I don't think this type is widely used (its odd representation in the REPL seems to confirm this) and any mathematical operation with it promotes it to another type, but I think that a decision should be taken about its status.
TODO list:
- [x] make `big(complex(pi, pi))` work (PR #21218)
- [x] fix `exp` (PR #21596)
- [x] make `sinpi(complex(pi, pi))` work (actually, not even `sinpi(pi)` works right now). Same for `cospi`. Requires #21219 (PR #21781)
- [x] fix `log1p`: can be fixed with `one(float(T))` in place of `float(one(T))` (which is also more efficient for Big numbers, only one number is allocated) if #21219 if merged (PR #21784)
- [x] fix `exp2` and `exp10`: see [this comment](https://github.com/JuliaLang/julia/issues/21204#issuecomment-289900420) below, requires PR #21219 (PR #21874)
- <s>make `complex(pi)` work (PR #22928)</s> The decision was to not make `complex(irrational)` work at all.
3 Likes