Codesnippets > Math

Complex Number Type w/ Functions, Demonstration and Mandelbrot

<< < (2/2)

Moru:
Ever heard of "keep your mouth shut not to show your stupidity?"
Or to be diplomatic: To speak is silver, to be quiet is gold.
We are many of this proverb :-)
(Freely translated from swedish, can't be bothered to look it up)

To say it clear. We just don't understand much of it :-)

CW:
Hi Moru.

LOL. We have your saying in the United States as well, and I can certainly relate to it. There are so many topics I feel ignorant about. This explains my deep dislike of trivia-type games.

"Which member of The Beetles was born first,  John Lennon, Paul McCartney, George Harrison, or Ringo Starr?"
Hmm.. Beats me.   :zzz:

"List the following continents in descending order, according to size (total land area); Europe, Antarctica, Asia, North America, South America, Australia, Africa."
Umm.. Asia... Europe?   :S

"What was the top YouTube music video in 2012?"
Ah.. common. Can't I have a science question instead??!   :giveup:

And so it goes.
Imaginary numbers, on the other hand, are really neat, useful, and very mind-twisty. I won't bore you with the mechanics. Let me try to blow your mind instead.

Imagine an ant clinging to a horizontal thread. That thread is the real number line you grew up with, the numbers you know and love. The ant can walk to the right, (1,2,3,4...) and he can walk to the left (3,2,1,0,-1,-2). The ant can spend his entire life on that thread and can count himself very happy because every number he needs is on that thread. How about Pi? Yep. It's there, between 3.0 and 4.0. So is e. So is the square root of 19723391. One thread, containing every answer to every math question which can be asked. But not so fast...

There is a dirty little secret lurking in the mathematical operations we learned in grade school. Addition, Subtraction, Multiplication, Division, Powers and Roots. The dirty little secret is this: There are answers to these operations which can not be found on the ant's number line thread. Consider exponents and roots. When we take the square root of a number, say the square root of 4, the operation is asking a question: What number, multiplied by itself, equals 4? The answer, of course, is two. But wait! That is not the only answer. Do you know what the other answer might be?

The other answer is negative two. Indeed, negative two times negate two equals.... FOUR. So for any root, there are two possible answers. But if that is so, then riddle me this:
What number multiplied by itself equals (-4)? What is the square root of negative four? This is a place where the operation bursts off the rails. Either something is wrong with the question, or the number line itself is not complete for it can not handle the answer to such a simple question. No such answer can be found on the ants skinny thread.

Is the number line incomplete? How could that be? It makes no sense, and yet if you push through the nonsense, using these impossible numbers in farther operations, you can wind up with a perfectly good and correct answer at the end of the line. This is what vexed mathematicians for years.  They couldn't make heads or tales of these impossible numbers, so they couldn't trust them, no matter how handy the final answers might be. These numbers were dismissed as untrustworthy, as fantasy, as IMAGINARY.

The name stuck. In time, mathematicians did figure it out. There really are an infinite number of numbers which are not on the ants number line, and they are every bit as real as any number you can name. These numbers, each individual number, has two parts; a real part and an imaginary part. This is a bit complex, so a much better name for imaginary numbers is to call them 'Complex Numbers'.  So where are they, these Complex numbers? They are there, right along side the real numbers. Stand on the ants number-line thread, facing forward or backwards. Turn 90 degrees to the right (or left), step off the number line and walk in that direction. You are now among the complex numbers, and an entire world has opened to you. No longer must you spend your life on a thread. Now you have an infinite plane to walk upon, a plane which contains ALL possible answers for ALL of the mathematical operations you learned about in school. The Complex Plane makes all of the mathematical operations complete.

What are Complex Numbers good for? All sorts of things. Complex Numbers show up throughout the core disciplines of mathematics, physics, electronics, even computer graphics.

In Trigonometry you may have studied ambiguous triangles, in which the dangling side of one edge is too short to reach either of the other two sides. The easy answer we are given in Trigonometry is that there is no solution to ambiguous triangles, but this easy answer is not so. There are answers to that sort of triangle, they just are not found in the real numbers.

Algebra and Calculus must deal with all sorts of imaginary roots. In fact, the nice easy answers on the real number line are the exception, not the rule. Instructors like to offer nice easy problems with nice clean solutions; but this implicit human favoritism often masks the reality that real life is messy.

It is a property of numbers that, when you multiply any number by an imaginary number, you rotate it by 90 degrees. This is very handy for computer graphics, so imaginary numbers can be put to work there.

Perhaps the most widely seen example using imaginary numbers is the rendering of Mandelbrot Sets and Julia sets, those magical mathematical fractal monsters which so mesmerize the eye and twist the mind with their infinite iterated design-without-a-designer. To those who suspected that Complex Numbers were not fully real, but just a fancy book-keeping method exploiting the 'real' numbers, the Mandelbrot says 'Not So!'. Every point in the Mandelbrot design is an individual number on the complex plane. Yet when these numbers are dropped into a laughably simple equation and fed back into itself a number of times, the Mandelbrot monster emerges in all its stunning glory. The Mandelbrot lurks on the complex plane and its presence shows that imaginary numbers are very real indeed.

The best part is that imaginary numbers and exploring the Mandelbrot Monster are within your reach. With these library functions GLBasic can handle complex numbers and you can write programs to do the rest. Imaginary numbers are fun.

Cheers!
-CW

Brick Redux:

--- Quote from: Brick Redux on 2013-Apr-27 ---Indeed, and life would become boring. 

I will tinker with your code and see what occurs.  Im the type of guy that (sometimes) takes something apart, puts it all back together and finds a few screws left over...cough :)

--- End quote ---

...and then the universe kindly balances everything out by showing you that those spare screws fit perfectly into the alarm clock you fixed - which until now had a loose case. COSMIC!...

Navigation

[0] Message Index

[*] Previous page

Go to full version