You need some way to cope with operations that don’t have real results for some values, such as log and sqrt of negative numbers
you can just represent those as a pair of real numbers, one for the real part, and one for the imaginary part. As long as you only (recursively) apply exponential and trig functions on those numbers, I believe you'll stay within the realm of complex numbers.
True, but I thought this was about real arithmetic not complex arithmetic
0/0, tan(pi/2), log(0)
I was replying to the sqrt and log of negative numbers. For undefined functions, I'd throw an exception