Is the language of complex numbers regular?

648 Views Asked by At

A complex number is a number that can be expressed in the form $a + bi$, where $a$ and $b$ are real numbers and i is the imaginary unit, that satisfies the equation $i^2 = −1$. In this expression, $a$ is the real part and $b$ is the imaginary part of the complex number.
Now, Assume that $C$ is the language of complex numbers.

Q1: Is $C$ a regular language?
Q2: Write a regular expression for $C$
Q3: Draw a DFA accepting $C$ if you can.

Note: I'm confused with the symbols. For example i don't know how to show $( \sqrt 2 , i )$ . I mean, $i$ is a non-terminal symbol. Can i have this symbol in my regular expression? The other problem is that i don't know how to show $( \sqrt )$.

1

There are 1 best solutions below

2
On BEST ANSWER

I can't answer all of your questions, but I can tell you how I would attempt to do it.

a + bi is made from 3 components, real numbers (a, b), operators (+) and the imaginary symbol (i). So we need to be able to express all 3. + and i are easy, it's just the symbol themselves.

So onto a real number, we can either write its decimal expansion (4.2) or with algebraic symbols (sqrt(3)/2). One of these is much simpler, but since you included sqrt, is say you need the latter.

Let's build up and see where we get to. 2 is easy it's just [0-9]. 42? [0-9]+

-7? (-)[0-9]+ sqrt(-7)? Oh, we don't want to be able to show, since that wouldn't be a real number. Sqrt(7)? (-)(sqrt)[0-9]+ sqrt(3)/2? (-)(sqrt)[0-9]+(/[0-9]+) sqrt(3/2)? (-)(sqrt)[0-9]+(/[0-9]+) But they are the same? Oh, we made a mistake, we forgot about parenthesis. From the pumping lemma, we can't describe parenthesis that are matched, so this definition is not a regular language. :/

Fine, lets pick the first way of expressing real numbers. I'm going to gloss over the steps here, since it is a quick google away.

(-)[0-9]+(.[0-9]+) where we escaped the . So that we know it's just a dot and not any single symbol.

Thus we say we can represent a complex number by [(-)[0-9]+(.[0-9]+)([+-][0-9]+(.[0-9]+)i)|[0-9]+(.[0-9]+)i)] Notice the second choice is so we can write 21, or -5i, but we can also write 3i and not be forced into +3i