Welcome to the Java Math Utils repository, a comprehensive collection of Java programs designed for mathematical computations. This repository includes a variety of tools and algorithms aimed at solving numerical tasks, from calculating square roots and solving Pell's equation to finding Catalan numbers and computing Fibonacci sequences. Whether you're a student, educator, or programming enthusiast, these utilities offer a practical exploration into the application of mathematical principles through programming.
Each program within this collection is crafted to demonstrate specific mathematical concepts and algorithms, making use of Java's powerful computational capabilities. The repository is structured to provide clear usage instructions for compiling and running each program, ensuring that users can easily navigate and utilize the tools provided.
Whether you're interested in the intricacies of number theory, the elegance of mathematical sequences, or the application of encryption algorithms, the Java Math Utils repository serves as a valuable resource for enhancing your understanding and skills in mathematical computing.
This class provides functionality for calculating square roots using the continued fraction representation. It is a prerequisite for running other programs that require square root calculations.
javac sqrt.java
Solves the Pell's equation x² - Dy² = 1 for a given value of D and finds the first n solutions.
javac pell_equation_solver.java
java pell_equation_solver [D] [n]
Calculates the square root of a number using the Pell's equation method.
javac pell_sqrt.java
java pell_sqrt [number] [digits]
Calculates the golden ratio using the Pell's equation method.
javac golden_ratio_pell.java
java golden_ratio_pell [digits]
Calculates the value of π using the Chudnovsky algorithm.
javac chudnovsky_bs_pell.java
java chudnovsky_bs_pell [digits]
Calculates the value of e raised to a given power using the Taylor series.
javac exp_bs.java
java exp_bs [x] [digits]
Benchmarks the performance of calculating square roots using BigDecimal's in-built sqrt method and the custom pell_sqrt
method.
javac SqrtBenchmark.java
java SqrtBenchmark
Finds the first n Catalan numbers.
javac CatalanNumber.java
java CatalanNumber
Computes the n-th Fibonacci number.
javac Fibonacci.java
java Fibonacci
A straightforward implementation of RSA encryption, demonstrating the generation of keys, encryption of messages, and decryption back to the original text.
javac RSA.java
java RSA
Calculates the arccotangent (acot) of a given integer x
to a specified number of digits n
.
javac acot.java
java acot
This program computes the arccotangent (acot) of a given integer x
to a specified number of digits n
. It also computes the arctangent (atan) of x
and displays the results in both radians and degrees.
This program computes acot(x).
Enter an integer x : 5
How many digits of acot(5)? : 10
acot(5) = 0.1973955598 rad
= 11.30993247°
atan(5) = 1.3734007672 rad
= 78.69006753°
Finds and prints all primitive Pythagorean triples with values between n1
and n2
.
javac PrimitivePythagoreanTriples.java
java PrimitivePythagoreanTriples
To use these utilities, clone the repository to your local machine and navigate to the desired program's directory. Compile each program using the Java compiler (javac
) followed by the program's filename. Run the compiled program using java
followed by the program's name and any required arguments as shown in the usage section for each program.
- Java Development Kit (JDK) 8 or higher.
Contributions to the Java Math Utils repository are welcome. Please feel free to fork the repository, make your changes, and submit a pull request.