Go Back   Science Forums
View Single Post
Old 03-08-2006   #29 (permalink)
Pyrotex's Avatar
Pyrotex
Slaying Bad Memes


Location:
Houston, Texas
Latest blog entry:
 
Pyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond repute
Send a message via MSN to Pyrotex
 



Not Ranked  0 score     
Re: Fractal Geometry of Nature

Quote:
Originally Posted by TheBigDog
I...Help me Pyrotex! Help!
"Here He comes, to save the day!"
Means that Pyrotex, is on the way!



Sure! Glad to help!
The basics of complex arithmetic:

We do CA on the Complex Plane, where the X-axis is "real"
and the Y-axis is "imaginary". All values up and down the Y-axis are considered to be multiplied by the square root of minus one, or "i".

"Numbers" in the CP correspond to points, with a real component and an imaginary component. For example, (3,4i) or (-17,-i).

Sometimes (often) complex numbers are represented as 3+4i or -17-i.

Assume two complex numbers A and C: (a,b,c,d are all real)
A = a + bi
C = c + di

--------------Complex Arithmetic:
ADDITION
E = A + C
= a + bi + c + di
= (a+c) + (b+d)i

MULTIPLICATION
F = A * C = (a + bi)*(c + di)
= a*c + a*di + bi*c + bi*di
= a*c + (a*d + b*c)i + b*d*(-1)
= a*c - b*d + (a*d + b*c)i

SQUARING
G = A squared = (a + bi)*(a + bi)
= a*a - b*b + (a*b + a*b)i
= a*a - b*b + (2*a*b)i

So, in the code you have trouble with, this is how the math works. We are squaring a complex value and then adding the complex value.

A^2 + A would equal
[a*a - b*b + (2*a*b)i] + [a + bi]

but it is easier to keep the squares in their own variable as you need them again for the iteration test.

Although the algorithm I gave you works just fine, technically you should ADD first THEN square. Starting with initial value zero: 0 + 0i. It works out the same except for calculating the distance of the new point from the origin. If you do it properly (Add, Square) then the distance from the new point A [a+bi] to the origin is:
distance = sqroot[ a*a + b*b ]

But it REALLY speeds up the algorithm if you avoid taking the squareroot!!!
So, instead of testing if distance <2
Rather, test if distance^2 <4
Distance^2 is just a*a + b*b, or in the code, asq + bsq.

Does this help???


----------------
Hypography Forums Moderator
-- - - - - -
What concerns me is not the way things are, but rather the way people think things are.
Epictetus, Greek Philosopher
The map is NOT the territory.
Korzybski, Polish-American Philosopher

Last edited by Pyrotex; 03-08-2006 at 11:05 AM..
Reply With Quote
 
» Advertisement
» Current Poll
Who's the sexiest man alive? Johnny Depp or Robert Pattinson?
Johnny Depp - 27.27%
3 Votes
Robert Pattinson - 0%
0 Votes
Someone else (please specify) - 45.45%
5 Votes
I'm too macho to think a guy is sexy - 27.27%
3 Votes
Total Votes: 11
You may not vote on this poll.


All times are GMT -8. The time now is 07:38 AM.

Hypography?

Hypography [n.]: A combination of "hyperlink" and "bibliography" - ie, a list of links to electronic documents. Comparable to discography and bibliography, but not cartography.

We have been online since May 2000, and aim to be the best place to find and share science-related content of all kinds.

Share the love!

Please add more science to your life. Use our RSS feeds on your blog, your portal, or your favorite feedreader!


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000-2009 Hypography
Part of the Hypography - Science for Everyone Network