Pi estimator in JavaFX
The program that uses randomly generated points on the Cartesian plane to estimate Pi number. I was inspired to write this program after I watched one of Joma Tech's video on YouTube. I've noticed most of programs don't use good-looking interface. I understand that the look is not the most important feature of a software. However, because I'm a programmer with an artist's soul I like if something looks good and I like to create good looking things.
How it works
The math behind it is pretty simple. First, we create random points on a Cartesian plane where we put circle with r = 1. Next we have to find how many points are inside the circle.

return ((Math.pow(point.getX(), 2) + Math.pow(point.getY(), 2)) <= 1); 
This is how we do that. This line of code implement the Pythagorean theorem. It checks whether the distance of point from (0, 0) position is greater than 1 or not.

Then we just need to divide number of points in the circle by all the points we have created. Because we used 1/4 of circle, the result must be multiplied by 4. That's it, we just estimated Pi number. More points we create better estimation we get.

This is an example of how much code we need to estimate Pi number. Without GUI there is not much writing. This problem is sometimes asked at job interviews for a software developer position. It might look simple but if someone didn't see this problem before it might be a bit tricky to find the solution.
How to achieve better estimation
To make better estimation using even a small number of points we have to do more estimations and calculate the average of their result. In that way even using 100 points we can make very accurate estimation with an error below 0.005

On the right side of the interface is a button with text 'advanced'. This button calls method that implements what I said above. It makes 100 estimations and calculates the average result
To check the code visit my GitHub - link
Pi estimator
Published:

Pi estimator

Published: