# Complex modulus? No, not the absolute value.

I was trying to make a class for complex numbers (VB.NET) but then I stumbled upon a problem. How do I define the $mod$ operator for Complex numbers?

First I asked Wolfram Alpha. It didn't help much. (But at least it told me it was possible to define).

Then, I searched Google, which didn't help much either. The most I found was this. Didn't help to clarify.

So I want to ask if any of you know how I could extend the $mod$ operator to the Complex numbers. Any help would be appreciated.

(P.S. I saw this question but I didn't see how the accepted answer answered it. What I want is a general formula for complex numbers.)

• Can it be defined? – user122283 May 6 '14 at 0:42
• @SanathDevalapurkar I told Wolfram to calculate some modulus with complex numbers and it managed to return values. Here's an example: wolframalpha.com/input/?i=%282%2Bi%29+mod+%283-5i%29 – Anonymous Pi May 6 '14 at 0:45
• Since $\mathbb{C}$ is not ordered (and since every element of $\mathbb{C}$ is either $0$ or a unit), I don't really know what this would look like. – user61527 May 6 '14 at 0:45
• @T.Bongers Maybe like this? wolframalpha.com/input/?i=%28a%2Bbi%29+mod+3 – Anonymous Pi May 6 '14 at 0:47
• If your're talking about Gaussian integers $\,m+ni,\,\ m,n\in\Bbb Z\,$ then they have a Euclidean division algorithm using the norm $\,m^2+n^2\,$ as a measure of size. If not, you need to say more for the question to make sense. – Bill Dubuque May 6 '14 at 1:52

I tried using some modulus formulas but they didn't give the same results as W|A. Then I tried using the "alternate representations". They didn't give the same results! I figured out it was a bug and managed to make this general formula: $$(a+bi)\bmod (c+di)=a+bi+(c+di)\lceil-\frac{a+bi}{c+di}\rceil$$ Hope this helps someone else!
P.S. $\lceil a+bi\rceil = \lceil a\rceil + \lceil b\rceil i$
• That doesn't look like it jibes with the results of the euclidean division algorithm. For instance, it seems very likely that there are cases where your definition would give $|(a+bi)\bmod (c+di)| \gt |c+di|$, which is the essential property for modulus. – Steven Stadnicki May 9 '14 at 18:26