Calculating the exact square root of a complex number with rational components

111 Views Asked by At

Given a complex number with rational components, I want to check if its square root also has rational components, and if so calculate the value. For example, given $-\frac{119}{225}+\frac{8}{15}i$ I want to get $\frac{1}{3}+\frac{4}{5}i$.

For some context, I'm writing an implementation of the Scheme programming language, which has exact and inexact numbers. A square root of an exact number should be returned as an exact number itself, if possible. And in this context, exact basically means rational, because everything else has to be expressed as floating point numbers which are inexact.

1

There are 1 best solutions below

3
On

$-\frac{119}{225}+\frac{8}{15}i=\frac{1}{225}(-119+120i)$

Let us use the classical method to find the two complex numbers $\pm(a+bi)$ satisfying $$(a+ib)^2=-119+120i.$$ The equation is equivalent to the system $\begin{cases} a^2-b^2&=&-119& \quad \text{real parts}\\ 2ab&=&120& \quad \text{imaginary parts}\\ a^2+b^2&=&\sqrt{119^2+120^2}=169& \quad \text{absolute values} \end{cases}$

The solutions are $$a+bi=\pm(5+12i)$$

As $225=15^2,$ we get$$-\frac{119}{225}+\frac{8}{15}i=\left(\frac{1}{15}(5+12i)\right)^2=\left(\frac{1}{3}+\frac{4}{5}i\right)^2,$$ the other square root of the given number is opposite, e.g. $\left(-\frac{1}{3}-\frac{4}{5}i\right).$