Answered in the FAQ:
https://julia.readthedocs.org/en/latest/manual/faq/#why-does-julia-give-a-domainerror-for-certain-seemingly-sensible-operations
They key concept is type stability.
Best,
Tamas
On Wed, Jul 22 2015, Joe Tusek <[email protected]> wrote:
Having come from Electrical Engineering with a Matlab background
and being new to Julia, I can't understand why assignment of
complex numbers was not automatic (e.g. sqrt(-3)). In many
scientific and engineering endeavours the occurrence of complex
numbers is very common and not always able to be predicted
beforehand with the complex result a natural consequence of the
data that was submitted to the analyses (which may just be time
series real data for instance). Whilst there are many things I
don't enjoy about Matlab the seamless integration of complex
numbers was a natural for those used to writing i or j to
denote a complex quantity. I can live with Julia's im syntax
although really I would rather be able to define it to something
I am used to, can I?
I guess though it is only the initial assignment of variables
that has to be explicitly defined as complex and the rest of
the code is written without explicit reference to its complex
type and hence looks very similar to the Matlab code it is
replacing?