# Imaginary Numbers

### #1

Posted 10 March 2011 - 06:02 PM

### #2

Posted 10 March 2011 - 06:07 PM

### #3

Posted 10 March 2011 - 06:14 PM

### #4

Posted 10 March 2011 - 06:17 PM

Also I don't know of

*any*programming languate that natively supports complex numbers. Real, string, float, double, boole are default data types, I have never seen "complex" as a data type. This is to be expected, since a complex number is essentially a vector with two coordinates (the real and the imaginary part), following a few special rules of arithmetic (the multiplication rule in particular). So to emulate complex numbers all you have to do is work with vectors of size two, and define the multiplication rule and the and

*n*th power root rule for those.

In GM this can be done with lists. I don't see exactly what's wrong with writing your own algorithms for complex numbers that work on lists of size two.

**Edited by Erik Leppen, 10 March 2011 - 06:18 PM.**

### #5

Posted 10 March 2011 - 06:31 PM

I mean,

**sqrt**(9) results in 3. (Because

*3 x 3 = 9*)

But,

**sqrt**(-9) also results in 3, that's because

*-3 x -3 = 9*.

Anaway, complex numbers indeed work a different way...

Maybe check out Wikipedia for that, maybe there's an alternative way of calculating it

**EDIT:**Typo...

-RefluxLtd

**Edited by Reflux Entertainment, 10 March 2011 - 06:34 PM.**

### #7

Posted 10 March 2011 - 09:23 PM

Matlab does, as does G/labview. However an imaginary number can actually be considered a simple vector with 2 components. Hence it is already in the suggestion/update list. (Adding the ability to create structures would enable this). Now only if we could overload functions (and operators) complex numbers would be as easy to use as real numbers. - The suggestion to use lists is pretty bad, it works but is very annoying to use (heck one can't even add lists and expect a simple vector addition). And because it is difficult to use it's error prone.What were you planning to use it for?

Also I don't know ofanyprogramming languate that natively supports complex numbers. Real, string, float, double, boole are default data types, I have never seen "complex" as a data type. This is to be expected, since a complex number is essentially a vector with two coordinates (the real and the imaginary part), following a few special rules of arithmetic (the multiplication rule in particular). So to emulate complex numbers all you have to do is work with vectors of size two, and define the multiplication rule and the andnth power root rule for those.

In GM this can be done with lists. I don't see exactly what's wrong with writing your own algorithms for complex numbers that work on lists of size two.

However for the calculations complex numbers DO help, and they should be considered a datatype just like "integers" and "floats" and "strings" are different datatypes.

@RE: you're wrong isn't defined in the natural space,

**because**-3 rimes -3 results to 9.

and by definition

### #8

Posted 11 March 2011 - 01:24 AM

### #9

Posted 11 March 2011 - 02:54 AM

Well, aside from a program devoted to solving equations, what purpose would it serve? You can only plot real numbers on a 2D graph, and in the end, that's essentially all Game Maker is supposed to do. I can't think of any conceivable purpose 'i' would have in an ordinary game. Perhaps I'm just narrow-minded?

Compare the following:

In other words, planar rotations can be thought of as multiplication of complex numbers. In particular, if a complex number has a magnitude of one, then it corresponds strictly to a rotation in the complex plane.

### #10

Posted 11 March 2011 - 08:52 PM

In order to impliment it, Mark would have had to recreate that function. Given that imaginary numbers is not in large demand for a game creation tool, then it wasn't worth it.

The same can't be said for your calculator, where the ability to use imaginary numbers is in demand.

### #11

Posted 20 March 2011 - 02:01 AM

But, ask yourself; in GM, a program designed and built to make simple 2D games, why would it need to understand the square root of -1? How many games would need it?

-MoK

### #12

Posted 20 March 2011 - 02:56 AM

If put into common practice, 2D games can benefit from complex numbers.But, ask yourself; in GM, a program designed and built to make simple 2D games, why would it need to understand the square root of -1? How many games would need it?

Complex numbers have applications in 2D geometry. Both the distance between two points and the angle from one point to another have elegant representations if the points are given as complex numbers. And as xshortguy has demonstrated, rotations work well with complex numbers.

You can also treat this as coupling x and y into one variable, allowing for easy storage in variables and use in various functions. Instead of putting in the coordinates as two arguments in a function, we can have the x coordinate as the real component and the y coordinate as the imaginary part, taking up one argument space. Now, search through the manual for functions that take coordinate values as arguments --- you can see that some of the arguments take up a lot of room.

If complex numbers are to be implemented into GM, I expect quaternions to be too --- they function in similar ways compared to complex numbers (except with two more components, j and k, whereas i^2 = j^2 = k^2 = ijk = -1). They greatly simplify coordinates used in 3D, especially with regard to rotations. And let's not forget how many argument spaces it would save for d3d_*() functions.

GameGeisha

### #13

Posted 20 March 2011 - 07:37 AM

GM understands strings and reals. Imaginary numbers don't properly exist; as any two numbers of the same type (positive or negative) will never be negative. 'i' was introduced as to allow mathematicians overcome this.

What? Imaginary numbers exist just as much as any other type of number. They come up because real numbers aren't "complete" in the sense that a polynomial with real coefficients may not have any real roots. With complex numbers this is not the case. A polynomial with complex coefficients always has at least one complex root (and, in fact, counting multiplicity there are exactly

*n*roots for an order

*n*polynomial). They have a number of other useful properties which help them unify a lot of methods in mathematics. As others have mentioned they do serve some use for geometrical operations among other things.

That said, I don't really think they serve enough of a purpose to include them as a specialized type.

### #14

Posted 21 March 2011 - 02:00 PM

Also if "structures" would be possible in gamemaker, we can start to effectivelly extend the number of "datatypes".

GM understands strings and reals. Imaginary numbers don't properly exist; as any two numbers of the same type (positive or negative) will never be negative. 'i' was introduced as to allow mathematicians overcome this.

What? Imaginary numbers exist just as much as any other type of number. They come up because real numbers aren't "complete" in the sense that a polynomial with real coefficients may not have any real roots. With complex numbers this is not the case. A polynomial with complex coefficients always has at least one complex root (and, in fact, counting multiplicity there are exactlynroots for an ordernpolynomial). They have a number of other useful properties which help them unify a lot of methods in mathematics. As others have mentioned they do serve some use for geometrical operations among other things.

That said, I don't really think they serve enough of a purpose to include them as a specialized type.

### #15

Posted 21 March 2011 - 06:48 PM

Also if "structures" would be possible in gamemaker, we can start to effectivelly extend the number of "datatypes".

Without operator overloading (or function overloading) anything that has a well-defined arithmetic will be somewhat ugly to use, however.

### #16

Posted 22 March 2011 - 05:28 AM

### #17

Posted 22 March 2011 - 08:01 AM

Wait, what? So instead of using 2 variables (x and y) to denote position in cardinal space...you want to use...2 variables (real and imaginary) to denote position in an off-the-wall space. How is that any more efficient? I especially ask this because last I checked, the monitor can only take x/y cardinal position...so you would still have to convert whatever formula you had through an algorithm to get it.Instead of putting in the coordinates as two arguments in a function, we can have the x coordinate as the real component and the y coordinate as the imaginary part

xshortguy shows us a rotation using imaginary math...but you would still have to convert it into and out of the imaginary space. How is THAT efficient over using the normal dot products and such?

I'm sorry if I sound daft when it comes to the 'i' world...but wtf is it needed for exactly in game making (that other more efficient forms of keeping it in realistic space can provide)? I can see this being used to possibly show mandelbrot sets (or the like), but I don't see how that relates to gaming (unless you are doing a "where's waldo" for the mini-bulb game -- yeah, that'll be popular among the kids).

Awesome, so instead of 3 variables (x, y, z), you want 4 (r, i, j, k) or possibly more?If complex numbers are to be implemented into GM, I expect quaternions to be too

Only in the minds of those willing to believe they can square root a negative number. I think MoK was stating it more in a realistic sense, that imaginary numbers are not actually "tangable" but a way to reduce other forms of math by going through a somewhat wormhole (imaginary space). As far as I know, 'i' is not an integral part of any microprocessor, so any methods you want will have to be done in software anyway...TI may make it a point to do extensive software on advanced trig/calc/wtfever concepts for their calculator (because their target audience are those in need of them), but I seriously doubt YYG will put that much effort into aImaginary numbers exist just as much as any other type of number

**game making**engine (which doesn't target the heavy math community directly).

I mean, it made sense to me...but what do I know, I'm only a simpleton.

### #18

Posted 22 March 2011 - 12:35 PM

In other words, in the minds of most educated people. Complex numbers are fundamental to every field of science and mathematics.Only in the minds of those willing to believe they can square root a negative number.Imaginary numbers exist just as much as any other type of number

Nor is pi, e, or the square root of 2. So what does that have to do with it?As far as I know, 'i' is not an integral part of any microprocessor

I'm not saying you're wrong about imaginary numbers not being critical for game making. But for god sakes, come up with some better arguments.

.

**Edited by chance, 22 March 2011 - 12:36 PM.**

### #19

Posted 22 March 2011 - 01:34 PM

And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

Regardless, I'm not saying complex numbers shouldn't be included; but as most of people that use GM are kids who have never even heard of them; is it reasonable for YYG to include them?

-MoK

### #20

Posted 22 March 2011 - 01:37 PM

"0" didn't exist in mathematics neither, or negative number at all for that matter..@chance: Well, the square root of -1 didn't exist in earlier mathematics. They didn't just sit down and go "Oh my, what shall we do now?"; they made 'i'. Just because I said they don't properly exist; doesn't mean I think they're a waste of time. To a computer, trying to actual square root a negative number is impossible. We know otherwise.

And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

Regardless, I'm not saying complex numbers shouldn't be included; but as most of people that use GM are kids who have never even heard of them; is it reasonable for YYG to include them?

-MoK

### #21

Posted 22 March 2011 - 06:59 PM

No, it's not reasonable. My post made that clear. My comments were aimed at Sabriath's uninformed comments about the nature of complex numbers, not his view on whether GM needed them....as most of people that use GM are kids who have never even heard of them; is it reasonable for YYG to include them?

That's false. Square root finders are software algorithms. And algorithms exist for complex numbers just as they exist for reals.To a computer, trying to actual square root a negative number is impossible. We know otherwise.

God that's dumb. Sorry, it's just... dumb. Do you think mathematical constants are "hard wired" into the silicon? lol....And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

.

**Edited by chance, 22 March 2011 - 07:01 PM.**

### #22

Posted 22 March 2011 - 07:01 PM

You might even say it'sGod that's dumb. Sorry, it's just... dumb.And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

*irrational*.

### #23

Posted 22 March 2011 - 07:51 PM

but you would still have to convert it into and out of the imaginary space

Such a conversion is trivial since you can easily access the real and imaginary parts of a complex number as easily as you can access the x and y coordinates of an object. In fact, representing rotations using complex numbers was so useful that someone decided to extend the complex numbers to quaternions which have really become

**the**method for representing orientation in 3D...in 1843. And in that case you not only get i, but a j and k as well. While (as I've mentioned) I don't see much utility in adding complex numbers themselves (especially since they can be very easily implemented as two real variables), the addition of quaternions would be very useful, especially if they came with methods for their conversion into rotation matrices for use in 3D.

And algorithms exist for complex numbers just as they exist for reals.

In fact, the algorithms are mostly the same for complex numbers as they are for real numbers.

To a computer, trying to actual square root a negative number is impossible. We know otherwise.

To a computer, anything but a finite subset of the integers is impossible. And yet we somehow managed to make them operate on things resembling real numbers (technically a finite subset of rational numbers). To a computer everything is merely a logical manipulation of a set of bits.

### #24

Posted 22 March 2011 - 08:44 PM

I am educated, I don't think about 'i' every second of my life. As for it being fundamental, ONLY to those fields, and those fields are worthless to humanity (except as hobby)...it's a fun escape from the real to find an abstract way to arrive at the same answer, but it is hardly a necessity of every day life. When a carpenter puts on a roof, he doesn't calculate square roots of negative numbers to arrive at a pitch (laymen)....up to the electronics designer who works with V=IR and other basic maths to determine circuit paths (and even then he uses SPICE which doesn't use 'i').In other words, in the minds of most educated people. Complex numbers are fundamental to every field of science and mathematics.

Although there are careers and fields of science out there that does make use of 'i', the question is are they getting anywhere? Wasting money to build a giant loop of coiled wires to watch atoms collide hasn't brought us flying cars or immortality (or anything useful except a bunch of papers written in the small community of scientists and hobbyists who care to read it).

Nor is pi, e, or the square root of 2. So what does that have to do with it?

An FPU (now integrated with the CPU) as far back as pentium's first days (roughly) contains a command to load pi in the register, as for e and sqrt of 2, I haven't checked any of the new datasheets. But regardless, those are tangable values (although irrational, they are contained in the 'real' side of math). In order to use 'i', you would have to alter how the processor performs all it's math operations by checking if the NAN is an 'i' and resorting to complex arithmetic instead. Processors don't do this, so it's not native, which means it has to be built up in software instead (and again, forcing YYG to go that route is absurd).God that's dumb. Sorry, it's just... dumb. Do you think mathematical constants are "hard wired" into the silicon? lol....

My position is that complex numbers are a thought and hobby venture more than practical. In that fact, it makes it useless in game making as well. Instead of voicing my opinion that GM doesn't need complex arithmetic and being shot down by those who have math backgrounds, I figured I would up the ante and show that it is practically useless altogether in life (kill the root and the veins starve).No, it's not reasonable. My post made that clear. My comments were aimed at Sabriath's uninformed comments about the nature of complex numbers, not his view on whether GM needed them.

What? Square root is a processor command (on FPU), and when you do a square root of a negative number, you get a NAN error.That's false. Square root finders are software algorithms. And algorithms exist for complex numbers just as they exist for reals.

Show me the math that would be required in rotating a point (x,y,z) around an origin (ox,oy,oz) by a set degrees (dx, dy, dz) in both the real and complex way....then look and see which one the computer will do faster (has less operations).Such a conversion is trivial since you can easily access the real and imaginary parts of a complex number as easily as you can access the x and y coordinates of an object. In fact, representing rotations using complex numbers was so useful that someone decided to extend the complex numbers to quaternions which have really become the method for representing orientation in 3D...in 1843. And in that case you not only get i, but a j and k as well. While (as I've mentioned) I don't see much utility in adding complex numbers themselves (especially since they can be very easily implemented as two real variables), the addition of quaternions would be very useful, especially if they came with methods for their conversion into rotation matrices for use in 3D.

But for a human to write 'i' next to a calculation isn't as hard as it is for a computer to constantly check every single number that goes into a calculation on whether it is real or imaginary ("hard" in this sense is cycles wasted and a loss of a bit precision for storage).In fact, the algorithms are mostly the same for complex numbers as they are for real numbers.

Now you're just being silly.To a computer, anything but a finite subset of the integers is impossible. And yet we somehow managed to make them operate on things resembling real numbers (technically a finite subset of rational numbers). To a computer everything is merely a logical manipulation of a set of bits.

### #25

Posted 22 March 2011 - 09:19 PM

You think all processor commands are magic? Two registers goes in and one comes out? Everything is done by algorithms. There isn't a logical element for sqrt(), so its usually expanded to a different equation. For example, sqrt can be written as , and now you can calculate it with logarithm (which also has a different algorithm which involves bit shiffting) and division by two which is also a bit shift. Basically, logical elements can only do addition, subtraction, multiplication by 2, division by 2 and inversion. Everything else is based on these elements. I once had a book which had algorithms for almost everything (sin, cos, log, ln, powers etc) done with these basic operations.What? Square root is a processor command (on FPU), and when you do a square root of a negative number, you get a NAN error.

I don't even want to reply to the rest of your post.

I doubt you understood what he meant.Now you're just being silly.

**Edited by HaRRiKiRi, 22 March 2011 - 09:31 PM.**

### #26

Posted 22 March 2011 - 09:59 PM

Where? I have never used them and I've designed and built a CPU from scratch (complete with rotary assignment, feedforward and back of registers, and pipelines with stalls).but Electronics use imaginary numbers A LOT

Oh, you mean waveform electronics, like SETI? Yeah, because that's important.For example, no spectral analysis would be complete (or even useful) without taking complex parameters into account

Pi was invented by man. The fact that the circumference of a circle relates to its radius may not have been invented by man...but the number that was derived from those observations was.You seem like the kind of guy who thinks Pi is invented by man

You're right, I'm not educated....merely passing with the highest scores in both ap calc and physics in the district for at least 10 years prior and after and having the, pretty much, born knowledge of circuitry and programming is hardly educated. That's borderline mentally challenged right?So I doubt you can call yourself educated (at least in mathematics, physicist, electronics or any other field that has imaginary numbers).

And? I'm sorry, but I don't see how that relates to me stating that "it is not native to the processor, so it would have to be built up in software" and "you lose 1 bit of precision and wasting time checking every number to make sure it's not imaginary before doing a calculation"? If complex numbers were THAT important, why doesn't intel, AMD and others build the next CPU with them native? I'm just not seeing the point that 'i' brings to the table where _other maths can be used to do the same thing_. As much as I love the beauty of mandelbrot and julia sets (and other fractals), to me, that's all they are...beauty, not practicality. They may have some coincidences (like logistic convergences), but again, just shows another way of doing math.You think all processor commands are magic? Two registers goes in and one comes out? Everything is done by algorithms. There isn't a logical element for sqrt(), so its usually expanded to a different equation. For example, sqrt can be written as {f}, and now you can calculate it with logarithm (which also has a different algorithm which involves bit shiffting) and division by two which is also a bit shift. Basically, logical elements can only do addition, subtraction, multiplication by 2, division by 2 and inversion. Everything else is based on these elements. I once had a book which had algorithms for almost everything (sin, cos, log, ln, powers etc) done with these basic operations.

I understood quite clearly...and I could have retorted with the fact that there is no actual "bit" in the machine either, it's actually just a build up of electrical energy on a small bit of metal which is continually recycled while releasing into other parts to allow even more electrical energy to either be blocked or pass. I didn't because I thought going that deep to create a strawman was silly, and I'm sure he knows it.I doubt you understood what he meant.

### #27

Posted 22 March 2011 - 11:18 PM

You think CPU is basics of electronics? CPU is just a very small part of a very large field. What you did was just a combination logical elements which you later simulated in a program (because I am sure you didn't physically build it). Did you consider how these elements worked or how the simulation program worked?Where? I have never used them and I've designed and built a CPU from scratch (complete with rotary assignment, feedforward and back of registers, and pipelines with stalls).

Spectrums are the basics of analog electronics, signal transmission, filters and so on. There wouldn't be any mobile phones, satellites, wi-fi or anything else if people didn't understand spectrums. You are clearly not educated in much of electronics. You know only digital 1's and 0's and that is the reason why you don't know the significance of imaginary numbers. You are just as limited as the computers themselves. And if you have this cynical point of view on every human technological advancement then you don't also understand the basics of science as a whole.Oh, you mean waveform electronics, like SETI? Yeah, because that's important.

May not have? Pi is a irrational number (thus infinite) and humans can't come up with something infinite. If a man invented pi then he would just make it 5 or something (or just 1) to make calculations easier. Pi is constant of 3.1415.. which is true in every part of the galaxy. Even aliens know pi and they have the same value for it. They of course will write it differently, but the value stays.Pi was invented by man. The fact that the circumference of a circle relates to its radius may not have been invented by man...but the number that was derived from those observations was.

Your egoism is only superseded by your ignorance.You're right, I'm not educated....merely passing with the highest scores in both ap calc and physics in the district for at least 10 years prior and after and having the, pretty much, born knowledge of circuitry and programming is hardly educated. That's borderline mentally challenged right?

And then why does CPU has instruction set for sqrt? Why can't we program it manually with "other maths"? As previously stated, things like quaternion are very useful in 3d graphics._other maths can be used to do the same thing_.

### #28

Posted 22 March 2011 - 11:40 PM

Me too. It's embarrassing to see an adult make such a fool of himself. Reminds me of when I was a boy setting up my first circuit (boy scouts). I concluded that electrical engineering was nothing more that connecting the positive and negative terminals.sabriath: Im sorry, but you are so wrong in so many aspects that it just makes me sad understanding you are not a troll.

I guess it's human nature to underestimate the importance of things we don't understand.

### #29

Posted 23 March 2011 - 01:23 AM

With that said, the name

*imaginary*is sort of a poor choice, since the construction of the complex numbers from the real numbers is quite a natural procedure. Without going into too many details, here are the highlights of the construction:

1. Start with the ring of polynomials with real coefficients R[x], i.e. things of the form , for some indeterminate x.

2. Consider the ideal I, a subset of R[x], generated by x^2 + 1. One can show that this clearly isn't R[x], since one cannot form the polynomial x from it. Furthermore, one can show that I is a maximal ideal.

3. Since I is an ideal, we can take the quotient ring R[x]/I. Since I is a maximal ideal, R[x]/I is a field. Moreover, from the fundamental theorem of algebra, the degree of the field extension [R[x]/I : R[x]] is degree two, so R[x]/I has two basis elements: things of the form (0 + I) and things of the form (1 + I). The first is a real number since (0 + I)(0 + I) = 0 + 0I + 0I + II = 0 + 1 = -1. The latter is not a real number: (1 + I)(1 + I) = 1 + I + I + -1 = 2I. So numbers in this field are can be written in the form a (0 + I) + b (1 + I), where a, b are real numbers. With a bit of cleanup, we can relabel things as the form a + b i, where (0 + I) is our 1, and (1 + I) is our i.

The construction of forming new structures by quotient rings is typical in the subject of abstract algebra. Once you get a feel for this type of construction, you'll see that complex numbers are really just an extension of the real numbers that allows for solutions to given polynomials.

### #30

Posted 23 March 2011 - 05:21 AM

The existence of pi was not developed by man; however, pi isn't something that nature developed. The 'concept' (probably the wrong word) was developed by nature. Nature didn't call it pi; we did. And you have no right to speak for aliens, they might not even have discovered (or even use) the value.May not have? Pi is a irrational number (thus infinite) and humans can't come up with something infinite. If a man invented pi then he would just make it 5 or something (or just 1) to make calculations easier. Pi is constant of 3.1415.. which is true in every part of the galaxy. Even aliens know pi and they have the same value for it. They of course will write it differently, but the value stays.

Regardless, the value of complex numbers, here, is in it's use for GM and (basic) game making. In saying that, it's next to useless (mainly due to its audience).

Whether the processor can or cannot use them, is neither here nor there. The only point I made was that imaginary numbers don't actually exist. I never said they're useless to the world.

-MoK

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users