Package de.hdm_stuttgart.sd1.math
Class Math
java.lang.Object
de.hdm_stuttgart.sd1.math.Math
This class implements a subset of functions from class
Math
using power series expansions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
exp
(double x) Approximating the natural exponential function by a finite number of terms using power series expansion.static void
setSeriesLimit
(int seriesLimit) static double
sin
(double x) Implementing sine slightly different by reordering terms.static double
sinOld
(double x) Calculating the sine by means of the corresponding power series.
-
Constructor Details
-
Math
public Math()
-
-
Method Details
-
setSeriesLimit
- Parameters:
seriesLimit
- The number of terms of a power series to be included.
-
exp
Approximating the natural exponential function by a finite number of terms using 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 bysetSeriesLimit(int)
}- Parameters:
x
- The exponential's argument as in \( e^x \)- Returns:
- The value \( e^x \) itself.
-
sinOld
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.
-
sin
Implementing sine slightly different by reordering terms.- Parameters:
x
- SeesinOld(double)
}- Returns:
- See
sinOld(double)
}
-