Class Math

java.lang.Object
de.hdm_stuttgart.sd1.math.Math

public class Math extends Object

This class implements a subset of functions from class Math using power series expansions.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    exp(double x)
    Approximating the natural exponential function by a finite number of terms from the corresponding power series expansion
    static void
    setSeriesLimit(int seriesLimit)
     
    static double
    sin(double x)
    Calculating the sine by means of the corresponding power series.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Math

      public Math()
  • Method Details

    • setSeriesLimit

      public static void setSeriesLimit(int seriesLimit)
      Parameters:
      seriesLimit - The number of terms of a power series to be included.
    • exp

      public static double exp(double x)

      Approximating the natural exponential function by a finite number of terms from the corresponding power series expansion

      \[ \begin{aligned} e^x ={} & 1 + {x\over 1!} + {x^2\over 2!} + {x^3\over 3!} + \dots \\ ={} & \sum_{i = 0}^\infty {x^i\over i!} \end{aligned} \] A power series implementation has to be finite since an infinite number of terms requires infinite execution time. The number of terms to be considered can be set by setSeriesLimit(int)}
      Parameters:
      x - The exponential's argument as in \( e^x \)
      Returns:
      The value \( e^x \) itself.
    • sin

      public static double sin(double x)

      Calculating the sine by means of the corresponding power series.

      \[ \begin{aligned} \text{sin}(x) ={} & x - {x^3\over 3!} + {x^5\over 5!} - {x^7\over 7!} + \dots \\ ={} & \sum_{i = 0}^\infty {(-1)^i {x^{2i+1}\over (2i+1)!}} \end{aligned} \]
      Parameters:
      x - The sine's argument as in \( \text{sin}(x) \).
      Returns:
      The value \( \text{sin}(x) \) itself.