The Math Behind Mandelbrot
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 66 | |
Author | ||
Contributors | ||
License | CC Attribution 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/37565 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Producer | ||
Production Place | San Antonio |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
Ruby Conference 201510 / 66
8
10
11
14
18
19
21
22
23
25
26
27
30
31
35
36
38
40
41
42
46
47
48
51
52
54
55
57
60
61
62
64
66
00:00
MathematicsMandelbrot setComputerSeries (mathematics)Slide ruleAxiom of choiceRevision controlLevel (video gaming)MathematicsGoodness of fitSet theoryExistenceLecture/Conference
00:36
Moment of inertiaEvent horizonComputerOnline helpSign (mathematics)GradientComputer programmingBitGroup actionSequenceSystem callCodeComputer sciencePrincipal idealLevel (video gaming)NeuroinformatikSelf-organizationComputer animationLecture/Conference
01:45
Online helpComputerComputer programmingMathematicsSocial classComputer scienceReal numberPoint (geometry)Self-organizationStudent's t-testData miningCodeComputer animationLecture/Conference
02:51
Lattice (order)Student's t-testComputerStatisticsCodeExecution unitComputer wormOnline helpCodeGame controllerGraph (mathematics)Block (periodic table)Web browserCountingAnalogyRight angleApplied mathematicsImaginary numberMathematicsReal numberComputer animation
03:31
Multiplication signImaginary numberAnalogyBitSet theoryMathematicsCalculationReal-time operating systemNeuroinformatikDoppler-EffektComputer scienceRule of inferenceEngineering drawingComputer animation
04:11
Complex (psychology)VideoconferencingRule of inferenceShape (magazine)DiagramMixed realityMereologyComputer animation
04:49
MereologyDiagramShape (magazine)Natural numberSelf-similarityFraktalgeometrieRight angleForcing (mathematics)Different (Kate Ryan album)Game controllerComputer animation
05:23
InfinityImaginary numberNumber theoryPlane (geometry)Forcing (mathematics)Different (Kate Ryan album)Branch (computer science)FraktalgeometrieGame controllerShape (magazine)Natural numberBitBridging (networking)Group actionImaginary numberMathematicsPoint (geometry)Multiplication signNumerical analysisInfinityTwitterGradientTerm (mathematics)VelocityPlanningCASE <Informatik>Thresholding (image processing)Electric generatorComputer animationLecture/Conference
06:58
Number theoryVelocitySquare numberRootInfinityNumerical analysisVelocityRootPoint (geometry)Real numberMathematicsNegative numberSquare numberSet theoryMultiplication signLevel (video gaming)Operator (mathematics)Positional notation1 (number)Condition numberQuicksortNumber lineDifferent (Kate Ryan album)Arithmetic meanTwitterFitness functionReverse engineeringBoundary value problemPosition operatorComputer animationLecture/Conference
08:53
RootSquare numberSquare numberRootMultiplication signMathematicsPower (physics)Negative numberTerm (mathematics)Rule of inferenceImaginary numberReduction of orderNumerical analysisCodeReading (process)Disk read-and-write headDivisorLevel (video gaming)QuicksortLecture/Conference
10:31
Number theoryPlane (geometry)Cartesian coordinate systemMandelbrot setVelocityInfinityKolmogorov complexityComplex numberVelocityTwitterAbsolute valueHeegaard splittingPosition operatorElectronic mailing listDistanceMeasurementInfinityIterationMereologyPlanningNumerical analysisSquare numberPoint (geometry)Set theoryGraph coloringMatrix (mathematics)Number lineCuboidFactory (trading post)Diagram
13:21
KettenkomplexClique-widthComplexity classGraph coloringComplex numberPoint (geometry)CodePlanningInheritance (object-oriented programming)InfinityRange (statistics)Heegaard splittingVelocityNichtlineares GleichungssystemReduction of orderSoftware testingAbsolute valueMaxima and minimaClique-widthComputer animationLecture/Conference
14:29
Convex hullRange (statistics)Default (computer science)CalculationIntegrated development environmentSocial classSquare numberComplex numberPoint (geometry)Bit rateSoftware testingRange (statistics)Multiplication signBitComputer animationLecture/Conference
15:16
Default (computer science)Numerical analysisTwitterInfinityPoint (geometry)Bit rateIterationZoom lensCircleFluid staticsComplex numberReal numberMereologyImage resolutionINTEGRALNumber linePRINCE2Computer animationLecture/Conference
16:39
CalculationRange (statistics)Integrated development environmentDefault (computer science)Host Identity ProtocolObject (grammar)Multiplication signComplex numberFraktalgeometriePhysical systemComputer programmingGraph coloringTelecommunicationSoftwareSquare numberProjective planeClient (computing)Locally convex topological vector spaceMathematicsBitMetropolitan area networkPoint (geometry)Film editingVirtual machineCuboidAreaMedical imagingSource codeLecture/Conference
17:34
Default (computer science)VaporExecution unitCodeObject (grammar)KettenkomplexJava appletMedical imagingVirtual machineZoom lensMultiplication signExpected valueJakarta CommonsCASE <Informatik>MathematicsProcess (computing)Image resolutionNeuroinformatikMetropolitan area networkComputer animationLecture/Conference
18:47
CalculationRange (statistics)Integrated development environmentDefault (computer science)Software testingNeuroinformatikWordVideoconferencingLink (knot theory)SpacetimeSlide ruleMobile appSpiralMultiplication sign2 (number)Goodness of fitYouTubeSource code
19:32
Default (computer science)Computer programmingGraph coloringSpiralCuboidMultiplication signBitMereologySoftware testingIterationPoint (geometry)Zoom lensTouchscreenDialect1 (number)Computer animation
21:24
Normal (geometry)MereologyLoginGraph coloringDemo (music)Level (video gaming)FraktalgeometrieMobile appComputer animation
22:31
Default (computer science)TouchscreenMultiplication signNumerical analysisAnnihilator (ring theory)GodPoint (geometry)Radical (chemistry)
23:13
Default (computer science)CalculationIntegrated development environmentRange (statistics)Annihilator (ring theory)Point (geometry)GodComplex (psychology)Multiplication signDisk read-and-write headInfinityElectric generatorComputer animationSource codeLecture/Conference
23:53
Range (statistics)Mandelbrot setIntegrated development environmentCalculationFraktalgeometrieHypermediaVideoconferencingCoprocessorGoodness of fitProcess (computing)FraktalgeometrieYouTubeReal numberComputer animation
24:44
AlgorithmMusical ensembleDemo (music)Wechselseitige InformationLine (geometry)Real numberComputer iconWaveDiagramCubeExecution unitDiscrete element methodInstance (computer science)Acoustic shadowGamma functionGame theoryVacuumMenu (computing)MIDIJava appletNormed vector spaceDuality (mathematics)Data miningWeb 2.0Link (knot theory)NeuroinformatikLine (geometry)Java appletElectric generatorPlanningScripting languageVideoconferencingCodeComputer animation
25:21
Data miningOpen setComputer animation
25:55
Menu (computing)FraktalgeometrieComputer-assisted translationResultantBit rateComputer-aided designFraktalgeometrieComputer animation
26:32
Associative propertyRankingLorenz curveBridging (networking)Convex hullMulti-agent systemMassPredictabilityAnalogyComputer simulationFrequencyParameter (computer programming)MathematicsMetropolitan area networkRow (database)Associative propertyMultiplication signComplex system19 (number)Initial value problemPredictabilityNeuroinformatikLattice (order)DecimalResultantSimulationComplex (psychology)Fraction (mathematics)Computer animationLecture/Conference
27:45
Lorenz curveQuantumWärmeleitungMathematicsFormal languagePerturbation theoryGreen's functionSet theoryGreatest elementPerimeterKettenkomplexInfinityMultiplication signTouchscreenGraph coloringPoint (geometry)AreaZoom lensVariable (mathematics)Initial value problemMetropolitan area networkComplex systemHypermediaVideo gameVirtual machineCuboidRight angleBoundary value problemResultantComplex (psychology)Mandelbrot setComputer animation
29:46
CurveDegree (graph theory)Category of beingStatisticsSimilarity (geometry)Scale (map)Computer-generated imagerySuperposition principleCharacteristic polynomialScatteringChromosomal crossoverExponentiationFraction (mathematics)Hausdorff dimension1 (number)Mandelbrot setEmailWeb pageClique-widthGreatest elementLengthMeasurementPolygonMedical imagingLengthMultiplication signNatural numberImage resolutionReal numberRule of inferenceMetropolitan area networkSatelliteArmBitLine (geometry)Source codeLecture/Conference
30:55
Mandelbrot setPredictabilityAssociative propertyHypermediaChaos (cosmogony)BlogFisher informationService (economics)Streaming mediaChaos (cosmogony)CodeRobotLink (knot theory)PredictabilityYouTubeFields MedalObservational studyLecture/ConferenceComputer animation
31:51
Router (computing)VideoconferencingMathematicsMandelbrot setStructural loadState of matterComputer-generated imageryGamma functionLibrary (computing)Link (knot theory)Menu (computing)Task (computing)Point (geometry)Normed vector spaceEmailSystem callVideo gameClosed setFraktalgeometriePerspective (visual)Set theoryMathematicsElectric generatorCombinational logicStudent's t-testLibrary (computing)SpeicherbereinigungComplex numberIntegrated development environmentBlack boxReflection (mathematics)Group actionImaginary numberForcing (mathematics)Social classRevision controlAlgorithmOpen sourceMultiplication signBitTask (computing)Data structureDirectory serviceZoom lensDifferent (Kate Ryan album)Cartesian coordinate systemProjective planeMobile appBuildingMereologyTraffic reportingMikrocomputerElectronic visual displayMotherboardDatabaseTouchscreenSoftware development kitCodeNumerical analysisGraph coloringPlanningSquare numberNeuroinformatikLengthRight angleObject (grammar)Mathematical optimizationTwitterParity (mathematics)VideoconferencingJava appletComputer fileSoftware testingStructural loadElementary arithmeticProcess (computing)Complete metric spaceSemiconductor memoryBootingPerimeterMedical imagingState of matterLevel (video gaming)CuboidRow (database)Server (computing)PrototypeGoogolCellular automatonWhiteboardDivisorMetropolitan area networkCurveSierpinski trianglePoint (geometry)AreaSymmetry (physics)SubsetStreaming mediaSource code
41:54
Menu (computing)Number theoryMandelbrot setScalable Coherent InterfaceSequenceNewton's law of universal gravitationAnnulus (mathematics)Function (mathematics)Inclusion mapComputer iconComputer-generated imageryGamma functionProcess (computing)FraktalgeometriePerimeterFinitismusControl flowPlanningMathematicsShape (magazine)Physical systemBridging (networking)DivisorNetwork topologyAreaBranch (computer science)Fatou-MengeComplex (psychology)Point (geometry)BlogInstance (computer science)Series (mathematics)CodeLine (geometry)TriangleGroup actionCASE <Informatik>BitMappingSet theoryObservational studyLecture/Conference
44:08
Videoconferencing
Transcript: English(auto-generated)
00:17
thank you for coming to my talk. I know it's a tough choice. There's a bunch of good stuff
00:20
I'd love to be seeing right now. This is not just a talk about the Mandelbrot set and the math behind it. I would just describe this as kind of the Discovery Channel version of this talk. There's not a lot of heavy math at all. But this is also a talk about why this talk exists. And it starts about three years ago with my boys. These are my triplets.
00:41
And I volunteer at their, they're in third grade now. I volunteer at their elementary school quite a bit through a program called Watchdog Dads. And I'd love to encourage everybody, the sequence I'm about to show here is about how I've gotten involved in some education in my county. And I'd love to be an inspiration, love to have this a call to action to you as well.
01:00
Through Watchdog Dads, I volunteer at the school occasionally. And two years ago, I took a week off of work and ran about 400 third, fourth and fifth graders through the Hour of Code for Computer Science Education Week. And let me tell you something, that was a blast. That was so beneficial to me, not just to the kids.
01:21
But I get a great quote from a fifth grade girl who said, oh, so computers aren't smart, they're just dumb really, really fast. Right? And that was so awesome to have that kind of influence and, you know, over kids. And I got some great material for talks, didn't I? And after I did this Hour of Code,
01:42
the principals talked to me about volunteering at the high school level through a program called TEALS. This is a nationwide organization where they're taking computer science professionals, just like us, and putting us in classrooms with math teachers who are not necessarily educated in computer science to bring the math teachers and the students up to speed
02:01
over a year or two to the point where the math teachers can take it over. And in my county, we already have a pretty active computer science department in high school. And so I have a great teacher that I get to work with. And one morning before school, I'm there an hour before classes begin a couple days a week
02:21
so we can, you know, go over homework and people can ask questions. A student of mine comes in and asks the math teacher from a previous class, another topic the day before, he goes, what is I good for anyway? Is it something useful? And you can see the teacher with that deer in the headlights look, oh no, the students asked me the real world question, what do I do? So I jumped in, I'll tell that story in a minute.
02:43
But the encouraging thing, another thing I'm doing in the county, last year we had 20 of my high school students volunteer to go back to their elementary schools and do the Hour of Code. So we had influence over some 2,000 kids in my county last year. This year, Computer Science Education Week
03:01
is doing an Hour of Code with Star Wars characters. The kids don't need to know anything, all they need is a browser. It's a little thing where you drag and drop blocks of code together and control stuff on graph paper. And it is so much fun. I'd encourage all of you to try to get involved in doing something with this with a local school. So the student asked, hello, what is I good for anyway?
03:25
And the teacher was like, well, it's used in some real world engineering, mathematics stuff, and I jumped in, I was like, oh, well first of all, if you do anything with analog circuitry, right, you need to know I, imaginary numbers, is what this is about, to calculate some of the waveforms,
03:41
some of the way the circuitry evolves over time. It's used in real time weather navigation to do the calculations based on Doppler radar, things like that, and of course my favorite topic, the reason we're here, to talk about the Mandelbrot set. But I was like, but you know, there's not enough time to talk about that now, it'd take me a little bit of time to talk about it. And the math teacher said, well,
04:01
Friday we have our computer science club, do you wanna talk about it there? And it was Wednesday, and I was like, uh, okay, I'll throw something together. That's where this talk came from. First I wanna show a few slides and talk about just the concepts we're gonna go into. The Mandelbrot set, the reason it's fascinating, is because there are a few simple rules
04:21
that we're gonna talk about to generate it. But it generates infinite complexity. If you saw that video that was playing as you walked in, you can keep zooming and zooming and zooming, and there is never a bottom. There's a top, which is this, and we'll talk about where that comes from. But as we zoom in, you see just more and more rich detail, and you see the same shapes reappear
04:51
in mixed up ways, like you see this thing, this is called the Mandelbrot beetle, that shape up top, or the bulb. The various parts of the diagram have names that go over.
05:01
And as you zoom in, you just find these shapes all over and over. I mean, we're looking at something, you'll understand what we're looking at in a minute. But this is the notion of self-similarity. And this is the fractal geometry of nature. You look at something like a galaxy, right? That has a lot in common,
05:21
even though it's completely different forces at work to create a hurricane. And again, it looks very similar, but completely different forces at work to create the foam in the top of our latte. It's the fractal geometry of nature controls how plants grow, controls how the shape of broccoli happens to look a little bit like your lungs
05:40
and the way it branches out. All that stuff is the fractal geometry of nature. There are three of three concepts I wanna talk about. One is trending, from zero to infinity. The other's imaginary numbers, and the other's mapping to a plane. So let's talk about trending. Two times two, what's that?
06:00
Okay, multiply it again, what's that? Hey, we keep doing that over and over, we trend towards infinity, right? That's third grade math. Interesting to generate case here is at one, we can multiply by one forever and it just stays at one. What happens if we .5 times .5,
06:22
over and over and over? That trends to zero. Does it ever get there? No, we just get smaller and smaller numbers. So let's talk about velocities. .9, what is that trend? So on this side of one, it trends towards zero, over and over, nine, .9, .9, goes to .81, .73,
06:44
something, blah, blah, blah. What about .99999? That also trends to zero, but it does it more slowly if we were to somehow take into account how many times it takes to cross some threshold. Again, slower still.
07:02
What about that one? That's trending towards infinity, but very slowly. So here's the concept of trending. Numbers other than one will trend towards zero or infinity at different velocities. And for real numbers, like .5, one, .2, 7.3,
07:24
it's pretty straightforward, right? I can, now that we know one's the boundary condition, I can throw a number out and you know what it is. So let's set that aside for a minute. That's the first idea we need to know. Let's talk about squaring numbers. So two times two is four. We can also write that little mathematical notation here.
07:43
We can say three squared is nine. Negative three squared is also nine. That's interesting, we'll come back to that. Let's talk about square roots. We have nine, of course three squared, we saw that written the other way a second ago.
08:00
Well, we have the reverse notation, just like we can add and subtract as a kind of an undo button for math. We can multiply and divide as kind of an undo button for math. Well, squaring has an undo operation and that's a square root and we write it like this. So the square root of nine is three, means three squared is nine.
08:20
What about the square root of negative nine? What can we multiply together to get a negative number? There isn't anything, right? Even if we had negative three and multiplied it by itself, we get nine because a negative times a negative is a positive. This is almost nonsensical, which is a little disturbing, isn't it? That, wow, square roots only work
08:41
for the first half of the number line. Well, we have a trick up our sleeve. Is the square root of nine negative three? Not really, it doesn't fit. Stand back, we're gonna try science. We start with the square root of negative nine.
09:00
We can rewrite that as the square root of nine times the square root of negative one. We know what the square root of nine is, it's three. So now we have this thing left over, this square root of negative one that doesn't make any kind of sense. With the math that's already built into our head,
09:21
maybe up to a junior high, first year high school level, this doesn't make any sense. We can just define that and say, it doesn't make any sense, but we're gonna put a label on it and start using it anyway. We're gonna call it i, an imaginary number. That, to me, is one of the powerful things of mathematics, that we have something
09:41
that we don't understand, so we just slap a label on it and start to use it anyway. We can now say that the square root of negative nine is three i. And we can say that three i squared is now negative nine. We have a way to go back and forth. So here are the rules for working with i. If you can ever refactor something
10:01
down to, wow, first time in this conference, I bet that was actually used for the math instead of the code term. If we can refactor something to a negative one and need to make the square root, we can just call it i. If we ever run into i squared, we can just call it negative one. That is this mind-blowing thing about math, is that we run into something that feels like a roadblock.
10:22
And if you look at the history of i, there were centuries where that was kind of a roadblock for people running into, until somebody just slapped a label on it and started using it. Now watch what we can do with that knowledge. Of course, we can't just add five plus three i. We don't know what this i thing is. It's like mixing apples and oranges.
10:41
So we just invent a new concept called a complex number. It has both a real part and an imaginary part. That's a real, or a complex number, 7.32 plus 3.04 i. We can have negative i's too, negative 6.4 minus 0.32 i.
11:05
Let's set that aside. I'm gonna put these two concepts together now. If we define a value to 1.2 plus 6.3 i, does that trend towards zero or infinity
11:22
if we start doing this to it? So instead of just on a number line like we could do before, we're gonna take that number and we're gonna put it on this complex plane. It fits right there where this red dot is. Now the neat thing, so we have the 1.2 is the real part
11:42
and the 0.63 i is the imaginary part. And it points right there. And we can imagine splitting this plane up into infinitely number many of positions. There's a way to figure out what's called the absolute value of a complex number.
12:04
And that is just its distance from zero on this plane. So we can use Pythagorean theorem, maybe I should put that in my bullet point list up front to be able to determine the distance. So even if it's negative three plus negative two i, we know its distance from zero.
12:24
So does it trend towards zero or infinity? That's hard to know. We can do this complex operation over and over where we're willing to say C zero is the point on this complex plane. And we're gonna say C one is the square of that and we're gonna add C zero back into it.
12:42
And C two is C one squared. We're gonna add C zero back into it. We just keep doing that. If it trends towards zero, we're gonna color it black. And that's part of the Mandelbrot set. If it trends towards zero or towards infinity, we're gonna color it based on the velocity. Now we had this notion of velocity before
13:01
but we didn't really have a way to measure it. We're gonna measure it now by how many iterations it takes for that absolute value to get greater than two. We can prove that if the absolute value is ever greater than two, we know it's going to accelerate towards infinity. How long does it take to get there is the interesting part of the question.
13:22
Ruby has a complex class. So this makes this kind of stuff super easy. We take a complex value. You can imagine splitting that point up into everything from negative two to two on one range and two to negative two on the other. Split it up into all these little pieces. And then testing each point to see what its velocity is.
13:44
And then just do this equation over and over. In fact, that's what this code does. We're gonna test the depth to infinity by passing in one of those complex numbers. We have a max depth defined that's just going to go over and over and over. And if we ever exceed the absolute value of two,
14:00
we're just gonna return our depth. Otherwise we return max depth. And believe it or not, that is all the code we're gonna need. That's the depth to infinity. And here's where we split up the plane. The width and the height. We take a left and a top value and we multiply it by this little fractional delta
14:21
to generate every complex number. We're gonna do depth to infinity. And we're gonna color a point, x and y, with whatever the depth is. Little bit of play time.
14:42
I have over here, Mandelrask, which will be up on GitHub after this talk at bakman slash mandelrask. And I can say rake dash t. And we have a few things to take a look at. I can say rake beetle.
15:01
So now right now that is drawing an 800 by 800 square, testing depths I think up to 128 I have it set to right now. On the ranges from negative two to two for the real part. And 1.2 to negative 1.2 on the imaginary part. And look at that.
15:26
With just a real number on a number line, it was pretty easy to guess what would happen. Greater than one trends towards infinity at an ever increasing rate. Trending towards zero, faster and faster at an ever increasing rate to zero with one stuck in the middle.
15:41
Well this, just by adding in this complex notion that I was able to walk you through in a few minutes, complex numbers, we get very different rates here of trending towards infinity. This circle out here, this is the circle for greater than two.
16:02
So that's like one iteration. In one iteration it was done. This blue, well it took two iterations to get there. This one took three, this one took four, this one took five, this one took six, this one took seven. More and more into all this stuff that at this resolution looks like static. Now in here we never trended towards infinity.
16:21
We just stuck around the zero point or trended towards zero. So we colored that black. I'm gonna zoom in now on this part. That is called seahorse valley.
16:41
Rake, seahorse. Now this one's gonna take a little bit longer to calculate because there is more black area and we're going a little deeper. So let's talk about what's happening here. We are, for an 800 by 800 square, so 64,000 points, we are iterating up to 128 times, creating new complex number every time.
17:04
I'm creating what, a million different objects here, doing a bunch of math to get this color point. This takes a long time. The first time I ran this in Ruby I was actually blown away with how long it took because the first time I ever messed with generating Mandelbrot fractals was 1991.
17:20
I did it on a room full of Macintosh LCs in my college lab that were for a networking project using the program to program communication toolbox on system seven. I wrote all these client machines that would calculate little squares and then a master machine that would take all the little squares and assemble them together. Drawing that Mandelbrot on a 512 by 314 image
17:42
took 14 minutes for a room to calculate. Yeah, yeah, I know exactly where the issue is. It's actually on the object creation of complex. There are things I could do, not use the complex type, not create so many objects. In fact, Charlie Nutter, it's a little faster
18:00
on JRuby as you'd expect. It's not faster, interestingly, using the Jakarta Commons collections complex from their math stuff, the commons math. And in Charlie Nutter's JRuby talk yesterday he was talking about how they're avoiding object creation in some cases. So we were talking about this at a break yesterday.
18:20
And he's anxious to see this code because this'll, you know, we can possibly make this much faster on JRuby by avoiding the object creation with the complex. So that didn't take too long to create. I mean, compared to 14 minutes with less resolution, a bank of computers, and this is Ruby.
18:40
You know, we rewrite this in Java or C and it's a lot faster. Let's zoom in one more time. This time with Seahorse 2. That video that I was showing as you walked in, that is available on YouTube. I have a link at the end of the slides. And that was four weeks of computer time
19:01
to calculate that video. There was a question over here? Okay, good question. So the question is why is that called Seahorse Valley? On the main beetle, also called the Cardoid, that valley, you might actually see it here in a second.
19:20
You'll see it in another app I'm gonna show in a second. The things that spiral off look kind of Seahorse-y. So somebody stuck the name Seahorse Valley just to have a name, because otherwise you're talking about this infinitely large space, it's hard to know. The butt of that beetle is called Elephant Valley. So this will be evident why it's called Seahorse Valley
19:40
in another program I'm about to use. But down in this static, depending on how you color it, these things spiral off and look like seahorses clinging to stuff. Now I mean, this looks a little color frightening here, right, there's a lot going on.
20:01
Let me show you Fractal Maker. This is an OS X download, it was like four bucks. I can reposition where I am by looking at this part of the screen, zoom in on Seahorse Valley and I can zoom.
20:27
And for lack of anything better, that's called Seahorse Valley. Also there's another one of these beetles zooming in. I'm now at a thousand times magnification,
20:48
5,000, 25,000, lost it just a bit. Now notice how it's getting kind of,
21:01
the edge is not defined anymore? This has to do with iterations. This is how many times I'm testing before I decide whether it turns towards infinity or zero. Otherwise I have to decide at some point when we're gonna color this thing or else we could just go on forever. So instead of 1,200 iterations, let's do 2,500 iterations.
21:34
Still not a ton, oh that's weird, it went back to 1,200 on me. 500, and it went back to 1,200 on me.
21:51
I don't know. I didn't write it, I just bought it. So we'll, okay demo fail on that but we'll move on.
22:00
The neat thing about this app, this app has a lot of other cool things. We can play around with how the color levels are picked because the colors aren't part of the Mandelbrot fractal at all. We're just assigning colors to stuff so we know how to look at it. So we can somehow have depth. The colors are something we just make up entirely on our own.
22:28
Totally ignoring the values I tend to type.
22:51
And there's a palette chooser. Let me, I'm just gonna pick a quick one.
23:04
It's probably off the edge of my screen. Well that's fractal maker. And the thing is you could sit there, I've done this, you sit there for quite some time exploring what's in that corner of the Mandelbrot fractal? You zoom in and I'm not necessarily a person of faith
23:20
but you sit there and you zoom in and you're like is there ever gonna get to a point where it says Dave, what took you so long? Signed, God. It's just there's so much complexity. Why should something, I mean it's philosophical, why should something that is so simple, right? I could explain these concepts to my eight year olds. They might not get the negative one but the basic, we're gonna do this
23:42
a bunch of bunch of times, right? And something that is understandable, something that fits in my head in the first 20 minutes of this talk can generate infinite complexity. So you might be wondering what practical use is this stuff? Cause after all he did ask me what is I good for?
24:03
And yeah this looks kinda cool. Maybe it's a bit philosophical but it doesn't really show what's good. Saw the YouTube video in the beginning. There are dozens of YouTube videos of people showing off their process or prowess generating Mandelbrot videos and coloring skills. But this is also used
24:21
in all kinds of other real world ways. There's a documentary in fact about the, not the third from my childhood, but the third Star Wars movies from the early 2000s where they talk about all the lava in that end scene, how they generated all that via fractal math.
24:42
And I have an example here of realistic terrain generation. It's a blog entry, there's a link to it in my notes. Talking about realistic terrain in 130 lines of JavaScript. This technique was pioneered by Boeing who was trying to make computer animated videos
25:02
of their planes in flight. And they wanted realistic mountains and backgrounds and all that kind of stuff in the background. There's a great documentary on that stuff on Netflix as well, it's called The Code. That's not what I want. I want the explore the otherworldly terrain.
25:22
Gives me a little chunk that is completely generated in JavaScript. That looks, you know, realistic enough to me. That kind of bumpiness, that is generated in the movie Toy Story. They would make plastic look slightly worn and edged with this exact same technique.
25:41
Let's generate it again. Minecraft uses exactly this technique to generate worlds based on a simple seed. I mean it's stunningly beautiful. If Bob Ross had drawn that,
26:00
we'd be like, oh, good job, thanks. Let's see, what else do I have? Back to my slides. Okay, so I was talking briefly there about some of the other uses of this.
26:22
Of course every talk of RubyConf needs a cat in it, right? So unexpected fractal result in the Schrodinger experiment. The fractal cats all the way down. So the first inkling of the complexity behind this mathematics wasn't discovered by Mandelbrot. It was actually discovered by Edward Lorenz.
26:41
He was doing weather simulations and huge iron in the 1950s. And he was trying to figure out weather over the period of days. How far can we realistically predict weather? And one time he decided to run a simulation that ran overnight, probably a fraction of a second on our modern computers, and he ran that overnight
27:03
two nights in a row with slightly different parameters and got wildly different results. It's like why would the 10th decimal place of the wind speed in this quadrant suddenly generate a tornado when it didn't yesterday? Our weather is a complex system like this.
27:21
This is where the quote, he published this paper, 1972 in the American Association, the Advancement of Science, 139th meeting. Predictability, does the flap of a butterfly's wings in Brazil set off a tornado in Texas? I'm sure you've heard this analogy, right? Now he's not saying that that butterfly yesterday is gonna create a tornado tomorrow here in Texas.
27:42
He's talking about whether initial conditions, you read this, the question that was really interest us is whether, for example, two particular weather situations differing by as little as an immediate influence of a single butterfly will generally alter sufficient time over, after sufficient time,
28:02
evolve into two situations differing by as much as the presence of a tornado. Now what does that have to do with the Mandelbrot set? The Mandelbrot set shows us this. We're looking at the thousand foot beetle at the top and we see a point and it's colored green. Or better yet, let me describe the edge of the Mandelbrot set.
28:21
We see a point that is colored green right next to the point colored black. Let's zoom in on that. Let's figure out where that boundary between the green and the black is. Oh, and all of a sudden in that boundary it's not green and black. There's green, pink, blue, purple, and black. What happened there? So zoom in again now between the purple edge and you keep zooming and you keep zooming infinitely
28:40
and you can never find the bottom. You can never find the edge. Just all this complexity comes out of it. So altering something by one gazillionth of a googolplex of a point of a value can generate wildly different results in what the Mandelbrot set looks like. With a complex system of variables
29:00
that's evolving over time, they're very sensitive to initial conditions. A pinball machine is like this too. Over time that ball can go radically different places based on the simplest things. The Mandelbrot set has no edge. That big black area in the middle,
29:21
it has no discrete edge that I can say this point is in, this point is out. The more I zoom in, I just find more and more points and more and more complexity. It has an infinite perimeter which is kind of mind-blowing. It has a set area, it fits on my screen, but an infinite perimeter.
29:50
Rookie mistake, Dave. Another example of this in the real world of nature is the question of how long is the coast of Britain. Coastlines are fractal, which is one of the reasons
30:01
why we can generate them in 130 lines of JavaScript and they look realistic to us. It triggers that sense of realism to us. If I measure, this is a famous paper by Benoit Mandelbrot. If I'm using a satellite image and a ruler that is about a mile in length and measure the coastline of Britain, I get one answer.
30:23
I zoom in a little bit now and I'm using something that's maybe a tenth of a mile in length because I'm on a boat on the shore and try to measure it, I get a longer coastline. I zoom in further still, I get a longer coastline still. I'm just always continually use something smaller so I'm at grains of sand trying to measure
30:40
the coastline of Britain. Every time I increase or decrease the resolution of my measuring device, I get an increase in resolution because I'm measuring more and more of those little eddies and little holes in the coastline. Benoit Mandelbrot has written a lot of books about this. Unfortunately, he died about two years ago.
31:04
The B in Benoit Mandelbrot, that allegedly stands for Benoit B. Mandelbrot. You can just keep tunneling down on his name. Here are my links to some of the information I've shared so far today. Mandelbrot Madness, which is a fantastic blog,
31:22
a great book called Chaos. There is a documentary called The Code, BBC. It was on Netflix. I believe now it's on a service called Curiosity Stream. I think it's also up on YouTube. It comes and goes all over the place. The paper, How Long is the Coastline of Britain? And predictability about the flap of the butterfly's wings.
31:42
There's a ton more information out there, but this is sufficient to satisfy a curiosity until you decide to go into this as a field of study. All my work is licensed under Creative Commons. You're free to use this. Use it for your own educational purposes. Please, take it to classrooms.
32:04
And in closing, as I take any questions, we'll just watch this deep Zoom video again. The song is Jonathan Colton. Any questions?
32:35
Sorry, what was that again?
32:40
Yes, I did. I actually also tried increasing the size of my garbage, or my heap, tried switching between various versions of Java, various versions of Ruby. In fact, I will show you one quick thing. We're supposed to be beyond Ruby, but I'll actually show you the code briefly. This was originally written
33:02
to illustrate a couple different concepts. Yes, where is my, there we go. First of all, I have an open source project called Rask, which is the Rake Application Starter Kit. I have, when I was consulting, I solved a lot of business problems with a combination of Rake and cron, right?
33:21
A Rake task to do something, set it up on cron, and woo, they're happy the report runs every night. The ETL runs between Salesforce and their database every night kind of thing. Well, we did that so often at my company, we created this thing called the Rake Application Starter Kit, because one time we were like, you know, we started with a bunch of Rake tasks.
33:41
By the time we were done, we were saying, you know, we just should have done a Rails app and never started with, never actually started the Rails server, because we wanted, you know, active record, we wanted the concept of a development environment and something else, you know, a production environment. We wanted all the common directory structure, so that's what we did. Rask is basically that directory structure
34:01
similar to a Rails app, built in testing, all that stuff, for doing Rake tasks. Second, this application senses whether we're on Ruby or JRuby, and uses different persisters to write out the file. So Ruby persister uses R magic, and the JRuby persister loads in a Java canvas
34:23
and saves it up. So I can switch easily between Ruby and JRuby. I was doing that for performance testing between 1.8.7, 1.9.3, 2.1, 2.2, 2.3, JRuby 9,000, with different garbage collection settings, and amazingly, Ruby as of 1.8.7 was pretty slow, but right now we have parity between Ruby and JRuby,
34:43
and Charlie yesterday was like, if we're just on parity, we can do better than that. So that's, if you check my Twitter stream, we were talking about it this morning, he wants the code. So yes, I've been doing some performance optimization on it. Right now the bottleneck is definitely object creation.
35:00
Anything else? Ah, the question is, how did I determine what complex numbers to use? Let me show you the beetle in my rake task.
35:21
The beetle, and this is well known, just the way the Mandelbrot set is defined. The left edge is 2.0, I'm sorry, the top edge, left edge is negative 2.0, the right edge is 2.0. The top edge is negative two, the bottom edge is 1.2. So that's where the numbers come from.
35:44
The way this syntax works is I say, what's the length I want, and it parses that up into little itty bitty parts. The code that actually does that is right here when I'm drawing.
36:00
We pass in a length, and this is in an object so we have a little bit of state here. I have a left and a top, which we pass in. It figures out this little bit of delta, and then just does 800 times for x and y, gives us a complex, and then does this depth to infinity. So, yep, the Mandelbrot set is a map
36:28
over the complex plane. And now I should also say that there are algorithms to compute this faster than this. Like you can make certain assumptions that if you're in the Mandelbrot set area,
36:42
and you do a complete perimeter around it, and it's all the same color, you can fill that square with that color. You've also seen that it has reflective symmetry over the imaginary axis. So we could just compute the top and reflect it down. There are tricks like that to speed up the processing of the Mandelbrot set. This brute force kind of shows the intent
37:02
of what the algorithm's really doing. It doesn't hide it behind any tricks. Any other questions? Yes. How do the kids respond? They loved it. I've since done it for Arlington Ruby and a few other places and decided to submit here,
37:20
but I'm in the school a couple days a week now, and they wrote their own version in Java, which is what they're learning in class. They've talked to me about it over and over on all kinds of stuff. In general, I've worked with those students in a lot of various ways, not just the little bit of time we've done in the classroom. This summer, well, shortly before school
37:42
it out last year, one of my students said to me, Mr. Buck, I wanna build a computer this summer. And I thought he was talking about ordering parts off of Newegg. And he said, no, actually, I wanna go old school. I wanna build something with chips and design it myself, design the motherboard myself. And I was like, wow, I don't know if you can do that with modern stuff. It's those sense of the timings and everything.
38:01
I did something like that in the 80s with a book called Build Your Own Z80 Microcomputer by Steve Circea. We did a Google search, and people still reference that book, use that book, and there are kits available based on that book. So we bought a kit, and we built, you know, he built one, I built one. We can actually boot CPM up on it.
38:21
And we got to prototype. We got to take individual chips out of it and put it on a breadboard and prototype, so I got to show him with LEDs how a 2K memory chip worked. It was really cool. Then my students are also involved in some high school coding competitions that take place at colleges. So it's a high school level, but sponsored by colleges. Really tough questions.
38:41
They have teams of four, four hours, 10 questions to solve pretty difficult problems. And we took a Coursera course on algorithms this summer to prepare some of the teams for that material. And you know, it's great when you have people that are so into something, they're willing to spend their summer on it
39:01
when they're supposed to be off. And in so many ways, you know, I don't call them kids, at least I try not to. They're my students, but it's kind of scary that I'm teaching these, you know, high schoolers that are only eight years older than my eight year olds. And they're only young adults.
39:21
It's like, what's gonna happen to my kids in the next eight years? It's scary. They are a few years away from being a peer, a mentor, a protege on a team I might work with. And they are really mature. And in some ways I feel, especially since I'm not a teacher at the school, I'm a TA. I'm officially a badged employee of the school,
39:41
but I volunteer my time. And the background check and all that happens through TEALS. But in some ways I feel like they're more just young friends I have than somebody I have an official relationship with. They work around town. The elementary school kids I teach, I see in the grocery store, and they're like, mom, mom, it's the computer guy.
40:00
And my high school students I run into at, you know, jobs they have in town. It's just really neat to, I'm really looking forward to the first crop of my students ending up in the workplace where I can run into them. I had a group of them to Ruby Nation last year, which is from a conference I run in DC.
40:23
Any other questions? I know I could. The question was if I looked into using any GPU for generation. There's actually quite a few libraries out there for doing Mandelbrot set generation. But that would, from this perspective of the code,
40:42
turn it into a black box. I'd give it parameters, I'd get an image back that I could display on a screen. And I really wanted to go into the what's happening, what's the meat. The speed wasn't the, you know, oftentimes when you optimize for speed, you obfuscate for clarity. And this was about the lesson, not the speed.
41:01
And the thing is, once you have the understanding, it's like, you know, you can write this in 20 minutes. Anything else? Let's take that last one.
41:25
Fractal math does not necessarily involve imaginary. Oh, the question is, what is the difference between fractal math and the Mandelbrot set? Summarizing that, the Mandelbrot set is a subset of the world of fractals. And fractals in general came about even before we had math to describe them
41:41
with things like the Sierpinski gasket, the Koch curve, and the snowflake, where, let me pull up, I think I have it in an entry here. There we go.
42:01
I'm gonna jump to fractals. I did not write this. This is somebody else's material that is awesome. It was a series by Xander, a series of blog articles about the Mandelbrot set. So let's say we start with a, this is the Koch snowflake, or Koch snowflake. Let's start with a triangle. And now every line segment, we're gonna replace,
42:24
you know, a third line, third triangle, third line to make that shape. We keep doing that, and we get these shapes that get pointier and pointier. And mathematically, he goes into this in the article, mathematically we can prove that these have
42:42
an infinite perimeter but a finite area. And mathematics knew about this hundreds of years ago, and it was kind of like, that's an aberration of what we wanna study with math, let's not worry about it. But there are a lot of these fractals that are self-similar is the real key there. The math of, you know, the shape of how broccoli grows
43:03
versus how your lung is put together versus your nervous system, possibly even the connectome of our brain, you know, when we're born, how is that complexity wired? You know, if you look at your lung, for instance, you know, it has a trachea, it branches into two. Little bit further down, it branches into two,
43:20
little bit further, branches into two, and it just keeps branching, branching, branching, branching, branching. Tree's the same way. Do you think all that is programmed, like hard-coded in our DNA? Or do you think our DNA probably has 30 lines of code that describe, that's what a lung looks like? I don't know, by the way, we're gonna reuse that to, you know, generate what the blood vessels in your foot look like.
43:41
That's where that math comes in. I is not necessarily involved in all of it, but the mapping of the complex plane involves the Mandelbrot set, the Julia set, a few degenerate cases of where we're, you know, we can use that spatial relationship on the complex plane to do stuff. I'm sorry, I'm sorry.