Skip to content

AlgebraicUtils

Aram edited this page May 4, 2025 · 3 revisions

AlgebraicUtils

Overview

The AlgebraicUtils class provides a variety of methods for algebraic and combinatorial calculations. This utility class includes methods to solve quadratic equations, calculate factorials, compute the greatest common divisor, and generate power sets.

Key Methods

  1. solveQuadraticEquation(double, double, double)
    Solves a quadratic equation using the quadratic formula.

    double[] roots = AlgebraicUtils.solveQuadraticEquation(1, -3, 2);
  2. factorial(int)
    Calculates the factorial of a non-negative integer.

    long factorial = AlgebraicUtils.factorial(5);
  3. calculateGCD(int, int)
    Computes the greatest common divisor (GCD) of two integers using the Euclidean algorithm.

    int gcd = AlgebraicUtils.calculateGCD(54, 24);
  4. generatePowerSet(Set)
    Generates the power set (all subsets) of a given set.

    Set<String> set = new HashSet<>(List.of("a", "b", "c"));
    List<Set<String>> powerSet = AlgebraicUtils.generatePowerSet(set);

Usage Notes

  • Error Handling: If an input is invalid (e.g., a negative integer for factorial), the method throws an appropriate exception and logs an error message.
  • Utility Design: This class cannot be instantiated, as it contains a private constructor and only static methods.

Clone this wiki locally