Hacker News new | past | comments | ask | show | jobs | submit login

It's not a fractal, but it is something familiar.

Multiply two complex numbers z and c is equivalent to taking z and applying a rotation and dilation to it, the rotation through arg(c) and the dilation through |c|. Division is the inverse of both, so z/c is z rotated by -arg(c) and dilated by 1/|c|.

What you're looking at, then, is taking the operation defined by c (rotate by -arg(c) and dilate by 1/|c|) and asking, if you take the Gaussian integers as the vertexes of a directed graph, what fraction of the vertexes are the source of an edge.

Consider the 1 dimensional analogy using real numbers. Given some real number c, take all the integers as the vertexes of a graph, and if z/c (for some integer z) is also an integer, I put a directed edge from z to z/c. When are these connected? Well, if c is irrational, never. If c is rational, then there will be an infinite number of connections, but how infinite? When c is 2, there will be twice as many edges on average in any subset of the source vertexes as when c is 4. If we can write c as p/q, then the smaller p is, the more edges we'll get, and the brighter the pixel in your image.

The 1 dimensional analogy will have a spike at 1/2, smaller spikes at 1/3 and 2/3, yet smaller spikes at 1/4 and 3/4, smaller ones yet at 1/5, 2/5, 3/5, and 4/5, etc. The spikes will all be distinct (because between any two rationals there is an irrational), but will be infinitely close (because the rationals are dense in the reals). As you keep zooming in, you will get more and more edges like this.

What you're seeing is a variation on the classical structure of the rationals dense within the reals.

Now, a fractal is a set with a fractional Hausdorff dimension. We have to extract a set from your function of c in order to talk about fractal dimension. We could take the support of the function (everywhere it's not zero). In the one dimensional case, that's the rationals. We could take level sets farther up (the set of c such that f(c) = k, for a constant k). Those are subsets of the rationals. However, the rationals, while dense in the reals, are of measure zero in the reals, and have Hausdorff dimension zero, and so do all the level sets. So it's not a fractal.

Doesn't make it any less pretty though.




I don't think this has anything to do with directed graphs. The operation looks like this. For nonzero c in C, compute the distance d(a(i+1)/c, Z+iZ) to the nearest Gaussian integer, where a is an integer.

The max distance is A = 1/sqrt(2) so color the point a(1+i)/c proportionally by

  (A - d(a(i+1)/c, Z+iZ))/A
I'm taking a liberty with the description, since computing "the percentage of a(i+1)/c's that are Gaussian integers" is open to interpretation, and if taken literally could mean something else entirely, such as computation of the ratio

  #(A(c,n)\cap Z+iZ) / n
where

  A(c, n) = { a(i+1)/ c : 1 <= a <= n }
which is asking for a proportion products that become Gaussian integers--this is a divisibility test. However, this doesn't show how to vary the brightness of the images.


"What you're looking at, then, is taking the operation defined by c (rotate by -arg(c) and dilate by 1/|c|) and asking, if you take the Gaussian integers as the vertexes of a directed graph, what fraction of the vertexes are the source of an edge."

This doesn't sound like a mathematical operation. Can you give a more mathematical definition of the full graph? For Gaussian integers a+ib, c+id, (a+ib, c+id) is a directed edge from a+ib to c+id if and only if what?

Whatever this directed graph (V, E) is, where V = Z + iZ and E \subseteq V \times V, it is not clear how the complex number c relates to the proportion of z in V such that there exists w in V with (z, w) in E. We have to know what E is before we can answer this.


OK, for a less abstract description, the site gives:

"For each complex number c calculate the following: For all gaussian integers g like 1+1i, 2+2i, 3+3i... when calculating g/c which percentage results in a gaussian integer again? The higher the percentage, the lighter the pixel."

So, Imagine you have:

   c = a+bi
   g = x+xi
Division by complex numbers is simplified with a trick of multiplying both numerator and divisor by the complex conjugate of the divisor, so we compute:-

  1 / c = c' / ( c * c' )
And we know that c * c' will always be real rather than complex.

  1 / c = (a-bi) / (a^2 + b^2)
Now it's just a case of iterating through the possibilities of g and seeing if g time this value of 1/c produces a gaussian integer again.

  x+xi * a-bi = ( x*a - x*b*i^2 ) + i*(x*a - x*b)

  = x ( a+b + i(a-b) )
So,

  g/c = x [ a+b + i(a-b) ) / (a^2 + b^2) ]             where g = x+xi
So for any g = x+xi this will only be a gaussian integer if both:-

  (a^2 + b^2) | x*(a+b)
  (a^2 + b^2) | x*(a-b)
And the original algorithm is testing all gaussian integers where 0 <= x <= 100

(Probably riddled with mistakes, should really be revising for my final Maths exam tomorrow morning...)


jc-denton replied, but appears to be hellbanned. His reply looks like this: ---

Humm tried to implement it simply using std::complex but it does not give me meaningful results. What did I do wrong?

template<class T> void CalcRealPercentage( const complex<T> from, const complex<T> to, const int intervalSize, std::vector<int>& intensityMap ){ auto height = to.imag() - from.imag(); auto width = to.real() - from.real();

    assert(intervalSize > 0 && height > 0 && width > 0 && from > 0);
    
    intensityMap.resize(width * height, 0);
    
    for (complex<T> c = from; c.imag() < to.imag(); c.imag(c.imag() + 1)) {
        for (; c.real() < to.real(); c.real(c.real() + 1)) {
            
            for (auto i = 0; i < intervalSize; i++) {
                complex<T> g(i, i);
                complex<T> result = g / c;
                auto imagPart = result.imag();
                if (imagPart == 0) {
                    intensityMap.at(c.imag() * width + c.real())++;
                }
            }
        }
    }


Seems to be after this comment: https://news.ycombinator.com/item?id=3468011

Not sure why he was hellbanned and not Zed after that little exchange.


Because readers of hacker news, as objective and spock-like as they like to think they are, really can't help but reverse-ad hominen when they vote. People are right because of who they are, not what they said. At the very least the bias appears as a benefit of the doubt.

PG should have, instead of removing vote totals, removed usernames. But of course that would get in the way of the ego stroking..

(I am of course no exception)


> Now, a fractal is a set with a fractional Hausdorff dimension.

Is there an authoritative definition of a fractal? The one you use rules out structures like Hilbert curves, which are generally considered fractals.


> Is there an authoritative definition of a fractal?

Sort of. I believe Mandelbrot's original definition required only that the Hausdorff dimension exceeds the topological dimension. And that kinda-sorta includes Hilbert curves, if you count them as topologically 1-dimensional.

But I've seen other definitions, including a rather hazy one that was not a definition in the formal sense, but just talked about properties that certain interesting sets tend to have: self-similarity, etc.

In any case, I have yet to find a situation in which the formal definition of "fractal" actually mattered significantly. (If someone knows of one, I'd be interested.)


No, it's pretty vague. http://en.wikipedia.org/wiki/Fractal#Characteristics Also, the Hausdorff dimension of a Hilbert curve is 2.


Thanks Madhadron, this makes a lot of sense. The Gaussian Numbers define a grid in the Complex plane. This calculation highlights complex numbers which represent best the ratios among Gaussian Numbers. It shouldn't be surprising to find such an ordered distribution.


madhadron: thank you for that explanation. In particular, I found your 1-dimensional analogy very helpful. Now that I understand the graph, I think it's even prettier. The beauty of these 'structural relationships' between numbers never ceases to amaze me.


I don't really get what you are describing. But perhaps you could provide a matlab script to show?


It is as fractal as this is: http://en.m.wikipedia.org/wiki/Hilbert_curve




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: