Header Ads Widget

Responsive Advertisement

The value of π = 3.14159 in java

 

The value of π (π≈3.14159) has a fascinating history spanning thousands of years, involving mathematicians, astronomers, and engineers. Here's an overview of how the value of π\piπ was discovered and refined over time:


Ancient Approximations

  1. Babylonians (c. 1900–1680 BCE):

Ø  The Babylonians approximated π as \(\frac{25}{8} = 3.125\) using geometric calculations.

Ø  They likely derived this by inscribing a circle within a square.

  1. Egyptians (c. 1650 BCE):

Ø  The Rhind Mathematical Papyrus suggests an approximation of π≈3.1605, calculated from the formula for the area of a circle.


Greek Contributions

  1. Archimedes of Syracuse (287–212 BCE):

Ø  Archimedes was the first to rigorously estimate π using geometry.

Ø  He inscribed and circumscribed polygons around a circle, calculating bounds: 3.1408<π<3.1429

Ø  His method of exhaustion laid the groundwork for integral calculus.

The story of Archimedes estimating π\piπ often emphasizes his use of inscribed and circumscribed polygons, but there’s an intriguing connection to the concept of circular motion, like a bullock cart wheel. While the exact method involving a bullock cart wheel isn't documented in Archimedes' works, we can conceptualize how similar ideas could have been used for approximating π\piπ using simple tools like wheels.

Here’s how a wheel could theoretically be used to approximate π:


1. Understanding the Circumference

Ø  The key property of a circle is that the ratio of its circumference (C) to its diameter (D) is constant and equal to π: \(\pi = \frac{C}{D}\)​

2. Using a Bullock Cart Wheel

A bullock cart wheel could provide a practical way to measure the circumference and diameter of a circle:

Step 1: Marking the Wheel

Ø  Mark a specific point on the rim of the wheel, such as where it touches the ground.

Step 2: Rolling the Wheel

Ø  Roll the wheel along a flat surface for one full revolution. The distance traveled is the circumference (C).

Step 3: Measuring the Diameter

Ø  Measure the diameter of the wheel (straight line passing through the center) using a rope or rod.

Step 4: Calculating π

Ø  Use the formula: \(\pi = \frac{C}{D}\)

Ø  For example, if the wheel's circumference is measured as 94.2 units and the diameter is 30 units: \(\pi = \frac{94.2}{30} \approx 3.14\)


3. Archimedes’ Rigorous Approach

While Archimedes didn’t use a wheel, he rigorously estimated π by inscribing and circumscribing polygons within a circle:

Ø  He calculated the perimeters of these polygons to get an upper and lower bound for π.

Ø  By increasing the number of sides of the polygons, he refined the accuracy of π.


Why a Wheel Approach Fits Archimedean Principles

Archimedes was a practical mathematician who often connected abstract geometry with real-world measurements. While his documented methods are more theoretical, using a wheel to approximate π aligns with his principle of leveraging geometry for practical problem-solving.


Educational Takeaway

This conceptual connection between Archimedes and a bullock cart wheel is a reminder of how mathematical principles can emerge from everyday observations and tools. It also shows how ancient mathematicians like Archimedes might have inspired practical approaches to exploring π.

 

 

  1. Ptolemy (c. 150 CE):

Ø  A Greek mathematician and astronomer, Ptolemy calculated π≈3.1416 using a 360-sided polygon.


Indian Mathematicians

  1. Aryabhata (c. 499 CE):

Ø  Indian mathematician Aryabhata approximated π≈3.1416 using astronomical calculations.

  1. Madhava of Sangamagrama (c. 1400 CE):

Ø  Madhava used infinite series to calculate π: \(\pi = 4 \sum_{n=0}^{\infty} \frac{(-1)^n}{2n+1}\)

Ø  This is known as the Madhava-Leibniz series, the first significant use of calculus for π.


Medieval and Islamic Scholars

  1. Al-Khwarizmi (c. 800 CE):

Ø  Al-Khwarizmi's work in geometry contributed to the understanding of π, though his exact methods remain unclear.

  1. Al-Kashi (c. 1424 CE):

Ø  Calculated π to 16 decimal places using a polygonal approximation.


European Renaissance

  1. Ludolph van Ceulen (1540–1610):

Ø  Calculated π to 35 decimal places using polygons with up to \(2^{62}\) sides.

Ø  His work earned π the nickname "Ludolph's number."

  1. Isaac Newton (1665):

Ø  Newton used his binomial theorem to calculate π to 15 decimal places.


Modern Era

  1. John Machin (1706):

Ø  Developed a rapidly converging formula: $$\pi = 16 \tan^{-1}\left(\frac{1}{5}\right) - 4 \tan^{-1}\left(\frac{1}{239}\right)$$

Ø  Used this to calculate π to 100 decimal places.

  1. Ramanujan (1910s):

Ø  Ramanujan developed extraordinary formulas for π involving rapidly converging series: \(\frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum_{n=0}^{\infty} \frac{(4n)!(1103 + 26390n)}{(n!)^4 396^{4n}}\)

  1. Computational Advances (20th–21st Century):

Ø  With the advent of computers, billions of digits of π have been calculated.

Ø  Yasumasa Kanada (1999): Calculated π to over 206 billion decimal places.

Ø  Emma Haruka Iwao (2019): Used Google Cloud to compute π to 31.4 trillion digits.

In 2019, Emma Haruka Iwao, a Google engineer, used Google Cloud Platform (GCP) to compute the value of π to a record-breaking 31.4 trillion digits. This achievement showcases the capability of modern cloud computing infrastructure. Here's how it worked and what it means:


Key Points

  1. Why Compute π to So Many Digits?

Ø  While calculating π\piπ to trillions of digits has no practical application in everyday life, it serves as a benchmark for testing computational power, algorithms, and the stability of software and hardware systems.

  1. How Was π Computed?

Ø  Iwao used the y-cruncher software, a specialized program designed for calculating π  and other mathematical constants to extreme precision.

Ø  The algorithm relies on highly efficient and advanced mathematical techniques, such as the Chudnovsky algorithm, known for its rapid convergence.

  1. Why Google Cloud?

Ø  Cloud computing allows access to a virtually unlimited pool of computational resources. For such a demanding task, GCP provided:

ü  Distributed computing: Using multiple servers working simultaneously.

ü  High memory and storage: Essential for handling massive data sets during computation.

ü  Stability and redundancy: Ensures uninterrupted calculations over long durations.

  1. Technical Details:

Ø  Duration: The computation took 121 days of continuous processing.

Ø  Resources Used:

ü  25 virtual machines (VMs) on GCP.

ü  Over 170 terabytes of data storage.

ü  High-performance processors and memory to handle trillions of iterations efficiently.

  1. Challenges Faced:

Ø  Storage and Memory: Managing 31.4 trillion digits requires significant storage and RAM.

Ø  Error Handling: Ensuring no errors occur during months-long calculations is critical.

Ø  Power and Uptime: Cloud computing resources must remain operational without failures for the entire computation duration.

  1. Result and Verification:

Ø  After computing π, the result was verified against existing records to ensure accuracy.

Ø  The new record (31,415,926,535,897 digits) was published and confirmed by independent organizations.


Significance of This Achievement

Ø  Technological Demonstration:

ü  Showcases the power of modern cloud computing platforms like GCP for solving complex mathematical problems.

ü  Demonstrates the reliability and scalability of cloud-based infrastructure.

Ø  Benchmarking:

ü  Provides a test case for high-performance computing and storage systems.

ü  Useful for debugging and improving distributed computing systems.

Ø  Mathematical Curiosity:

ü  A tribute to humanity's enduring fascination with π and mathematical exploration.


Fun Fact

The number "31.4" trillion was chosen as a nod to the digits of π itself: 3.14.

This record demonstrates the convergence of mathematics, computing, and engineering, pushing the limits of what modern technology can achieve.

 

 

 


 

To compute a custom approximation of π in Java, we can use various mathematical formulas and techniques. One popular method is to use an infinite series approximation, such as the Leibniz series:

$$\pi = 4 \left( 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \dots \right)$$

Here’s how you can implement this in Java:


Custom Implementation of

Java Code

public class CustomPi {

 

    public static double calculatePi(int terms) {

        double pi = 0.0;

        boolean add = true; // Track whether to add or subtract

 

        for (int i = 0; i < terms; i++) {

            if (add) {

                pi += 4.0 / (2 * i + 1);

            } else {

                pi -= 4.0 / (2 * i + 1);

            }

            add = !add; // Alternate between addition and subtraction

        }

 

        return pi;

    }

 

    public static void main(String[] args) {

        int terms = 1000000; // Number of terms for the series

 

        // Using custom implementation

        double customPi = calculatePi(terms);

 

        // Comparing with Math.PI

        System.out.printf("Custom π (using %d terms): %.15f%n", terms, customPi);

        System.out.printf("Built-in Math.PI: %.15f%n", Math.PI);

        System.out.printf("Difference: %.15f%n", Math.abs(customPi - Math.PI));

    }

}

 

 


Explanation

  1. Parameters:
    • terms: The number of terms in the series. More terms yield a better approximation.
  2. Logic:
    • Alternate between addition and subtraction for successive terms in the series $$\frac{1}{1}, -\frac{1}{3}, \frac{1}{5}, -\frac{1}{7}, \dots$$
    • Multiply each term by 4 to compute π.
  3. Comparison with Built-In π:
    • Java's Math.PI provides an accurate value of π to compare against.

Output Example

For terms=1,000,000:

 

Custom π (using 1000000 terms): 3.141591653589774

Built-in Math.PI: 3.141592653589793

Difference: 0.000001000000019

 

 


Key Takeaways

Ø  π originated from the study of circles, specifically the ratio of a circle's circumference to its diameter.

Ø  Its exact value remains unknown, but it is irrational and transcendental (not the root of any polynomial with rational coefficients).

Ø  Advances in π calculations have paralleled developments in mathematics and technology.

This journey of π showcases the power of human curiosity and ingenuity in understanding mathematical constants!

The value of π
The value of π

 


For More sort information, visit:

Ø  Selection Sort with iteration wise per step

Ø  Insertion Sort

Ø  Bubble Sort with each iteration how it is work

Ø  Merge sort of Each step how it is working

Ø  Quick Sort per iteration what happen

Ø  Sorting of country

Ø  Sorting Of a list multiple attribute wise two technique

Ø  Seat Arrangement in Sorting Order Like 1A-1E, 3C-3G etc

Ø  How to sort 10 billion numbers

Ø  Merge Sort simple under standing

 

For Math information, visit:

Ø  Calculating the area of a triangle

Ø  The method for calculating the area of a rectangle in Java


For Design information, visit:

Ø  Design pattern

Ø  Mastering Design Patterns Practical Implementation Tips

Ø  How to draw sequence diagram and other diagrams using plantuml

Ø  Time Analysis for Congested Routes Using Shortest Path Algorithms

Ø  Java Design Pattern

Ø  Passive Infrared (PIR) sensors understand and implementation by java





Post a Comment

0 Comments