Pi calculating from Mandelbrot Set using Julia

Join Trial or Access Free Resources

There should be no such thing as boring mathematics.

Edsger W. Dijkstra

In one of our previous post, we have discussed on Mandelbrot Set. That set is one of the most beautiful piece of art and mystery. At the end of that post, I have said that we can calculate the value of $\pi $ using Mandelbrot set. So, today we will be doing exactly that.

Today our main goal is to write a Julia programming language. Well, I am using Julia as I am learning this new language and it's really great and also, "Mandelbrot" and "Julia" set are related. So, why not use Julia language.

It all started in $1991$. On that year, Dave Boll discovered a surprising occurrence of the number $\pi $ while exploring a seemingly unrelated property of the Mandelbrot set. So, let's see.

Discovery

It all started when Dave Boll was trying to see if the neck of the mandelbrot set ($c=-0.75+i\cdot 0$) is infinitely thin or not. We was trying to find this by taking a number $\epsilon $, which is as small as we want (in simple terms $\epsilon \to 0$) and apply the recurrence relation $z = z^2 + c$ where $c$ is taken as $c = -0.75 + i\cdot \epsilon$.

Now, we see the number of steps it needs to go outside of the mandelbrot set.

$\epsilon $No if Iteration needed to go out
1.03
0.133
0.01315
0.0013143
0.000131417
0.00001314160
0.0000013141593
WTF

What the !!... It was exactly the reaction of Boll, when he first saw this. Somehow the digits of $\pi $ was generated.

Let's take an example to see what is happening. Let's start with $c = -0.75 + \epsilon i = -0.75 + i $. Now, we apply the algorithm of Mandelbrot set. This is shown in the image below.

Calculation for $c=-0.75+i$

This picture clearly shows the algorithm. After taking the $c$ value, we apply the iteration. That iteration has $3$ values of $z$ ($z_0$,$z_1$,$z_2$) before the value of $z$ goes outside of the mandelbrot set. And as you have guessed the number is the first digit of $\pi $.

As we decrease the number $\epsilon $, the number of steps needed by the $z$ to go outside the mandelbrot set increases as seen in the table. In the limit $\epsilon \to 0$, the number needed will generate the exact value of $\pi $ (This value actually goes to infinity).

It doesn't just work for $-0.75 + \epsilon i$ but also works for $(0.25 + \epsilon )+ 0i $, $-0.75 - i\epsilon $, $\cdots $

The same for $0.25+\epsilon +0i$ can be visualized using a parabola. This can also be compared with a reflective system formed by a parabolic and straight mirror. The number of reflection will generate the value of $\pi $.

The proof of this a bit technical. If you want a proof read this - Proof of this Phenomenon.

Programming using Julia

The code is very simple to write. Remember in Julia the imaginary $i$ is represented by $im$.

The code for the case $\epsilon = 0.1$ is shown below.

As you can see it's so easy and it is giving me $33$. And if you have noticed... in Julia we can use symbols like "$\epsilon $".

Now, what we can do.. we can make a function from this and let's also use a function called setprecision to get high precision to decimal values to get many digits of $\pi $. We will also be using BigInt and BigFloat to handle high precision.

So, The final code is:

This function takes $n$, which is the number of digits you want in $\pi$. Now, let's see some of it's output.

Notice, the number of digits are correct up to $n-1$ places.

Beautiful!!.. Isn't it?

We can visually see the path like shown below:

This is all for today. I hope you learnt something new and have grown a bit.

More Posts
A Major Milestone in Young Research: Aaditya Punatar and Muskan Sadana Publish in JEI

A Major Milestone in Young Research: Aaditya Punatar and Muskan Sadana Publish in JEI

October 11, 2026

Publishing original scientific research in a peer-reviewed journal is an achievement many scholars work toward for years. Achieving this feat early in one's academic journey requires exceptional intellectual rigor, creativity, and persistence. Aaditya Punatar and Muskan Sadana have reached this remarkable milestone, successfully publishing their collaborative research paper in the prestigious Journal of Emerging Investigators […]

Read More
Prishaa Shrimali Named Grand Finalist at Regeneron ISEF 2026 for Quantum-Powered Urban Planning Research

Prishaa Shrimali Named Grand Finalist at Regeneron ISEF 2026 for Quantum-Powered Urban Planning Research

October 6, 2026

Her project on quantum-accelerated Steiner trees for 15-minute cities earned a place among the finalists at the world's largest pre-college STEM competition. Prishaa Shrimali of Marymount School of New York, was selected as a Grand Finalist at the 2026 Regeneron International Science and Engineering Fair (ISEF) in Phoenix, Arizona. Her project was Optimizing Urban Accessibility: […]

Read More
ISI M.Stat Entrance Success Story 2026

ISI M.Stat Entrance Success Story 2026

June 27, 2026

In 2026, the following Cheenta students have been successful for Indian Statistical Institute's M.Stat Entrance. They ranked within the first 50 in the entire country in these entrances. I.S.I. M.Stat Entrance

Read More
ISI B.Stat-B.Math and CMI BSc. Math Entrance Success Story 2026

ISI B.Stat-B.Math and CMI BSc. Math Entrance Success Story 2026

In 2026, the following Cheenta students have been successful for Indian Statistical Institute's B.Stat Entrance and Chennai Mathematical Institute's B.Sc. Math Entrance. They ranked within the first 200 in the entire country in these entrances. Most of these students attended the problem solving workshops regularly, which happen 5 days every week. CMI B.Sc. Math Entrance […]

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2010 - 2025, Cheenta Academy. All rights reserved.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram