Hacker News new | past | comments | ask | show | jobs | submit login
The Sierpinski triangle page to end most Sierpinski triangle pages (oftenpaper.net)
333 points by pr_fancycorn on Oct 8, 2013 | hide | past | favorite | 55 comments



That's amazing. It just goes on and on with beautiful plots. About halfway down, there's a section on understanding the Riemann sphere:

> From what I can tell, one of the settings used to deal with division by 0 is the so-called Riemann sphere, which is where we take a space shuttle and use it to fly over and drop a cow on top of a biodome, and then have the cow indiscriminately fire laser beams at the grass inside and around the biodome. That's my intuitive understanding of it anyway.

And there's even animation (with Mathematica source) for this one. However:

> (Note the cow cannot be spherical or it will roll off).


I'll attempt a layman's explanation of a Riemann sphere for anyone who has no idea what this is about:

The Riemann sphere lets you deal with dividing by 0 by adding one more point to the complex plane: ∞[1]. Imagine putting it in the air above the origin, 0, and folding the midpoints of the four sides of your graph paper to meet there. (Yup, put all 4 points of the arrows in the same spot!) That's the Reimann sphere[2].

Going from a point the sphere back to the plane is a little weird.

1. Put a cow (point) on the top of the biodome (sphere) at infinity.

2. Pick the point on the sphere that you want to give a home on the complex plane.

3. Have the cow fire a laser beam (draw a line from infinity) through the point.

4. Follow that line back to wherever it hits the plane. That's the equivalent point on your complex plane.

Play with this a bit. Points near the top of the sphere (near the cow, at infinity) will shoot laser beams way off into the distance. Points near the bottom of the sphere will burn the grass right nearby on the plane itself.

You can then reverse the process ("If my cow were to shoot a laser at this grass, what part of the the biodome will get hit?"), to go from the plane to the sphere, because "folding up the sides of paper" doesn't accurately model what happened to make the sphere.

[1] Math with ∞ is what you'd expect: 3/0 = ∞. 3/∞ = 0.

[2] Since there is an infinite number of points on a sphere, this is entirely possible, and only mildly unsettling.


That sounds similar to the projective space used in computer vision.


Maybe it's because Riemann sphere is nothing else but a complex projective line, but I guess the reason you feel they're related is that both of these are manifolds which are created by performing certain identifications of points inside flat prototypes.


the geometric rationale - the axiom of parallel lines.

On classic, Euclid, plane a pair of parallel lines would never intersect. Given a line and a point outside of the line, there can be only one line through the point which would be parallel to the first line.

If one modify the axiom to allow for many such lines through the point (the lines which would never intersect the first line) - that would result in hyperbolic plane geometry.

If one modify the axiom to state that no such line through the point is possible (i.e. any line through the point would intersect the original line) - that would result in the Riemann sphere geometry.


(I am not a mathematician) but if you want an actual explanation of the Riemann sphere, I really like the one given in "Visual Complex Analysis" by Tristan Needham. It's really very cool. Google books may have it.

This site is amazing though. It just keeps going...


Uh, wow, I think they earned that claim. There's so much in here, they even have a cow which fires lasers being dropped from a space shuttle. http://www.oftenpaper.net/img/understandingtheriemannsphere....

seriously going to have to look more closely at this some time, it's fascinating in a "look what you can do with math/programming/mathematica" kind of way.


"This cow does not cower. Infinity cannot bully this bull, cannot bloviate this bovine. By all appearances this cow is wearing infinity on its mane."


For those who happen to have Mathematica, try this to get a smooth, high-resolution interactive fractal explorer (make sure you have a C compiler installed):

  JuliaFP = Compile[
    {{const,_Complex}, {init,_Complex}}, 
    Module[{val=init,n=0},
      While[Abs[val] < 5 && n < 25, val = val^2 + const; n++];
      {Mod[Arg[val]/(2*3.14159), 1], 1 - Abs[val]/5, 1 - Abs[val]/100}
    ],
    CompilationTarget -> "C", 
    RuntimeAttributes -> Listable, 
    RuntimeOptions -> "Speed"
  ];
  
  {fine, coarse} = Table[Complex[j,i], 
    {dx, {0.008, 0.002}}, {i,-1.5,1.5,dx}, {j,-1.5,1.5,dx}
  ];

  pt = {0.0,0.0};
  Graphics[{
    Raster[
      JuliaFP[Complex @@ pt/2, If[ControlActive[], fine, coarse]], 
      {{-2.0,-2.0}, {2.0,2.0}}, 
      ColorFunction-> Hue
    ],
    Locator[Dynamic[pt]]},
    ImageSize -> 800
  ] // Dynamic
P.S. Original post is awesome. I love the cow!


Thank you for this. I tried looking around for the "best fit" for a Mathematica work-alike that is Free software, but came up somewhat short. The closest I could find was Gnu mathics, but it doesn't appear to be very complete (ie: many Mathematica examples won't work). Other alternatives are SAGE and of course Julia -- and I guess SAGE would be the best for "playing" or "live coding"?

Anyone have any insights?

I'll also note that Mathematica looks quite awesome indeed.


One of the Julia creators did a fractal demo [1] recently, including the Sierpinski triangle. Julia is now quite nice for interactive work via the IJulia notebook (IPython kernel for Julia). As a bonus, it does not require a C compiler to get good performance.

[1] http://nbviewer.ipython.org/url/beowulf.csail.mit.edu/18.337...


IPython is catching up with the Mathematica frontend, slowly but surely. And that Julia demo is nice -- though I don't think a procedural language like MATLAB is the best model for a scientific language in this day and age.

We (Wolfram) are working on a web frontend for the Wolfram Language that will make the language "effectively" open, even if it is still proprietary.

And after the next version, we're going to be concentrating hard on defining a typed subset of the language that can compile via LLVM to all kinds of targets, including the browser.


It's tough to catch up with Mathematica when you guys keep putting out such awesome stuff with each new version. It's been great to see Wolfram innovate so much – versions 6, 7, 8 and 9 were all amazing releases (especially after the four-year gap following 5). I found the new symbolic discrete calculus work in 7 and the symbolic statistics capabilities that built on that in 8 to be particularly mind blowing [1][2]. This seems like it was the fruit of a focused, long-term R&D agenda.

Regarding Julia, although the syntax is superficially similar to Matlab and we've intentionally made many things compatible, Julia isn't really modeled on Matlab. Julia is much more influenced by Lisp – much like Mathematica via Macsyma and Maclisp. Julia's dynamic multiple dispatch is somewhat reminiscent of Mathematica's pattern matching dispatch system too, although, of course, the evaluation semantics are radically different.

I hate to quibble, but having a web frontend for Mathematica that you don't charge people to use does not make it "effectively" open. Mathematica is a shining example of excellence in closed-source software and I have no problem with it as such, but calling it "open" because there is a web version is just disingenuous b.s.

[1] http://www.wolfram.com/products/mathematica/newin7/content/D...

[2] http://www.wolfram.com/mathematica/new-in-8/probability-and-...


Another cool thing about the Sierpinski gasket is that it's possible to more or less do calculus on it. You can even define a Laplacian operator. There's actually a whole class of fractal-like sets on which this is possible, but SG has always been the prototypical one.


I also thought about implementing a language that bases on this, a language that sees the world in all it's shapes as raw numbers, a matrix, renderable as graphs. This is so freaking awesome, that I cannot stop thinking about the crazy new ideas this injected into me and suspect that I'm probably becoming a numberphile.

Interestingly, I was just reading the Book (hardcover) with the recursive Title: "The Fractal Geometry of Nature" by Benoit Mandelbrot. And this brings an entirely new meaning into my world view after combining the ideas behind this and http://en.wikipedia.org/wiki/Multifractal_analysis#technique...


That is truly impressive and mostly all over my head. I feel that somewhere on that page we should be able to find a graphical solution to the factorization of large primes unless maybe that code would need to run on a computer residing in the fourth or fifth dimension?


>That is truly impressive and mostly all over my head. Glad i am not alone


Holy mother, this person is cool and this person's website is cool, too: http://www.oftenpaper.net/ (it even has an article on Arc coroutines, ha!)


I especially like the way they present images + source as annotations in their article.


No rss feed? :(


So cool. Fractals were the thing that got me into high-level math and programming, back in high school. One of these days I'm going to go re-implement a bunch of the fractal-generation algorithms.


Not nearly as comprehensive, but interactive w/ d3:

http://roadtolarissa.com/triangles

Only a couple of lines of codes too:

https://github.com/1wheel/BizarreSierpinskiTriangle/blob/mas...


s/a couple of/59


Is is just me or is the code source really hard to understand? It's cool that you can represent such complex shapes with just a few lines of code in Mathmatica, but without comments and with all the single letter variables, it's hard for me to follow what's going on.


I agree, but do realize this is written for a mathematical audience, not a CS audience. It's reductive, but it's not that reductive to your average math major/grad student.

Code by/for mathematicians is particularly ugly to a professional programmer. There is significant historical (pencil & paper) precedent for what single-letter variables represent in a given context. For a mathematician, ConstantArray[0, {m,n}] reads more cleanly than ConstantArray[0, {cols,rows}].

Similarly, seeing variables like p1, p2, p3 is off-putting to me as a programmer, but I still immediately recognize them as 3 arbitrary points in a triangle.


That makes sense; I'm not the target audience. It was just a little off-putting to see some code and think "Whoa! That reminds me of Perl golf!!".


This is one of the annoying things about Haskell code -- since many Haskell programmers come from math backgrounds, they tend to use very short variables, often one letter or a letter and a number, where a programmer would use a descriptive variable. Perhaps more annoyingly, as a result of this lineage, it's become part of the convention, so even those who come from a non-math background tend to use short, mathy variable names.


But why pick two letters, m and n, which are pronounced almost exactly the same way? That broke my brain so badly at uni on so many occasions, especially with non-native-speaking lecturers :(


(author here) I wanted to mention that I'm not a mathematician, or anything in particular. Any math grad should know comfortably more than me. I'm basically just a "hobbyist of everything," like a "midget polymath" who, by the way, happened to drop out of a terrible college. In fact I originally started that blog because I was having trouble finding a job (for a very broad spectrum of reasons, not least of which that I'm as bad at speaking as I am good at writing). I think most of the content on that page is approachable by high school students, since the most complicated stuff is really just basic trigonometry and complex numbers.

My intent was to wander into quote-unquote "advanced topics" but not necessarily dwell on them, so the math is intended to be casual, even though I didn't hold back on the formulas. I.e. you're not supposed to understand everything. From a larger point of view, you could think of the page as a response to the inanity of the logic-only expositional style that passes as higher math education today.

Regarding the code, to me most of the code snippets on that page are "scripts." There's maybe 2 or 3 snippets that might cross over into being "applications." The MovieMaker[1] utility is probably the most application-y. (Apologies for having to squint at the code in some cases. I felt that the visceral immediacy of the source code was critical, in the "this is not magic" kind of way, which is why it's all plaintext rather than, say, links to Mathematica notebooks.)

For better or worse, however, the source was one of those places where I had trouble holding back. I tried to make the code educational in the process, though. In particular, if you want to learn or expand on function-oriented/functional programming skills, the code may learn you some insights.

By the way everybody, thanks for the comments. It's been hilarious/endearing reading them, and I'm happy that one of my minor magnum opii is irreversibly burning such a healthy number of man-hours from the coffers of society. I should also mention that all the imagery/source/audio is public domain. Also if you want to link to a specific slide view, View Source/Inspect Element on it to find its name (the CSS class is "flipbook"). So if you see

  name="game of life 2"
That becomes

  http://www.oftenpaper.net/flipbook-gameoflife2.htm
Where it has its own page. Of course, my inimitable laziness is why this process isn't automated.

[1] http://www.oftenpaper.net/flipbook-fadeleafanimation.htm


This is amazingly cool and stimulating to think about. It's also a compelling reason to take another look at Mathematica. The code is clearly dense and hard to understand, but I wouldn't even know how to go about performing some of these computations in another language.


I really wish the licensing for Mathematica weren't as strict; it's a fantastic language that would be everywhere if it had a free "community version" or something. I used it very extensively in college and then took advantage of the $500 lifetime professional upgrade for new graduates. Now I do server-side development and data science at a startup, and I often work on problems that could solved efficiently with a few lines of Mathematica code. I'll use it for one-time internal scripts, but due to Wolfram's licensing you can't just bake it into your server code. Not to mention, it's nearly impossible to find engineers who have much experience with it since you can't exactly download it and hack on it like you can with the alternatives.

Don't get me wrong, it's a powerful tool and well worth it's price. But adoption is extremely low outside of academia, and I don't see that changing anytime soon unless Wolfram adopts more developer-friendly licensing. Which is a pity because it's definitely the "right tool for the job" in a lot of cases.


A few years ago, I accidentally found this way of creating a Sierpinski Gasket-like structure:

https://vimeo.com/7690310

Lines "flow" from left to right (horizontally) or bottom to top (vertically), and all lines start out white. When two lines cross, they might switch color depending on which color they come across, as follows:

* white (h) + white (v) = black (h) + black (v)

* black (h) + black (v) = black (h) + black (v)

* white (h) + black (v) = white (h) + white (v)

* black (h) + white (v) = white (h) + white (v)


What you've got there is a truth table for the XOR bitwise operation.

    HV | O
    ---+---
    11 | 0
    00 | 0
    10 | 1
    01 | 1
You can do it very similarly with the coordinates of the pixels on the screen[1]. It's really interesting how often that shape comes out of places. Which is why I think that this page got started.

[1] http://www.stilldreamer.com/mathematics/sierpinskis_triangle...


I designed a system of cellular automata based around this idea of colliding lines. You can play with it at http://sciencevsmagic.net/logicgrid

The XOR Sierpinksi's triangle is at http://sciencevsmagic.net/logicgrid/#282800 but there are other ways make it too. For example XNOR makes an inverse http://sciencevsmagic.net/logicgrid/#828200

If you keep hitting random you'll find plenty of surprising analogues to Sierpinksi's.


XOR is addition mod 2, which is the same reason you get Pascal's triangle mod 2 is sierpinski gasket.


Note that where binary operations on screen coordinates tend to produce Sierpiński's triangle, ternary operations will produce Sierpiński's carpet (I don't know what happens as you increase bases beyond that, the number of possible operations does explode).


Totally amazing...it is itself a fractal of information, I want to go into a recursion of link-following!

Can't resist posting my Clojure implementation of the chaos game: https://github.com/Hendekagon/card


I was thinking about Sierpinski triangles recently, and trying to relate it to the 3 4 5 triangle. The 3 side has a Sierpinski triangle, with 9 segments, equaling 3^2. The 4 side has an equivalent "Sierpinski square", with 16 segments, equaling 4^2 (basically four squares touching at the corners with an empty square space in the middle, forming a cross shape). Then I was going to show how the two shapes could be combined to equal 5^2, or come up with its own shape (a house seems best, as the regular pentagon tiles the plane so the line totals don't work out).

As of yet, fruitless. It's a cute little project that shades of the standard presentation of three squares forming a center 3 4 5 triangle, with an interesting twist.


Regular Pentagon does not tile the plane.


http://i.stack.imgur.com/bGpfy.png You're right, thanks. So if the inner space is shaded, it produces the "Sierpinski pentagon", and this can be iterated indefinitely.


I was going to say not all Sierpinski pages, because I didn't expect to cover CGR with genomes. But it covers it! My version: http://8iterations.in/cgr_hanako


He also mentions Lisp several times in his blog. That alone would rate a front page mention on HN. But seriously, what a wonderful smile-inducing website and page.



He did not. Fractal Flam3's are the chaos game.

to quote:

  1 start at any point. call it p
  2 pick one of the three vertices at random
  3 find the point halfway between p and that vertex
  4 call that point p and draw it
  5 goto 2
He goes into great depth about this strategy.


i don't mean flames in general, i mean that particular image, which is a spherical version of the sierpinski with rotation.


I've just spent the last hour or so at this site ( found via reddit/math ) and it is pretty amazing. Well worth a look! Also the link at the end to mathics was new to me and looks interesting.


Did some Sierpinksi triangles for TOH a few years back: http://www.exocortex.org/toh/


Triforce spotted :)

Nice to come across some fellow Zelda fanboys unexpectedly.


Just about ended my Chrome session, until I killed the tab.



2b ∨ ¬2b

Clever.


Well, I suppose this is a decent start... ;-)


Gonzo mathematics !


At least the guy's enthusiastic


One fractal to bind them all…




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

Search: