|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvec_math.Math2
public class Math2
Provides some more sophisticated mathemtical functions. All methods are static.
| Nested Class Summary | |
|---|---|
static class |
Math2.Airy
|
static class |
Math2.InterQuartile
|
static class |
Math2.Newton
|
static class |
Math2.Spline
|
| Field Summary | |
|---|---|
private static double |
ACCNEWTON
Default accuracy to reach with Newton's root-finding. |
static double |
DOUBLE_NORM
Smallest normalized double. |
static double |
ERRF1
The value of the error function at (1/sqrt(2)) for 1-sigam dev. |
static float |
FLOAT_NORM
Smallest normalized float. |
static double |
FWHM
Multiply sigma of a normal distribution with this to get the FWHM. |
static double |
LN10
The natural logarithm of ten. |
static double |
LN2
The natural logarithm of two. |
static double |
LN2PI
The natural logarithm of two. |
private static int |
MAXNEWTON
Maximum number of iteration in Newton's root-finding. |
static String |
NAN
A string representation of NaN, different to the question mark. |
static char |
PM
The plus-minus char. |
static double |
SQR2
The square root of two. |
static double |
SQR3
The square root of three. |
static double |
SQRLN12
The square root of minus the natural logarithm of 1/2. |
static double |
STD2IQR
For a normal distrib. |
| Constructor Summary | |
|---|---|
Math2()
|
|
| Method Summary | |
|---|---|
static int |
aoverb(int a,
int b)
Return a over b. |
static double |
arcosh(double x)
Area cosinus hyperbolicus. |
static double |
arsinh(double x)
Area sinus hyperbolicus. |
static double |
artanh(double x)
Area tangens hyperbolicus. |
static double |
confine24h(double arg)
Special use of confinePeriod for angles in hours. |
static double |
confine2PI(double arg)
Special use of confinePeriod for angles in radian. |
static double |
confine360(double arg)
Special use of confinePeriod for angles in degrees. |
static double |
confinePeriod(double arg,
double period)
Periodic arguments are reduced to first intervall, 0-360. |
static boolean |
contains(double[] arr,
double val)
Returns true, if the double val is found in array arr. |
static boolean |
contains(Object[] arr,
Object val)
Returns true if the target object is found within the object array. |
static double |
cosh(double x)
Cosinus hyperbolicus. |
static Number[] |
cubicEquation(double a,
double b,
double c,
double d)
Solves a cubic equation of form |
static Vector2D[] |
cubicSpline(Vector2D[] tab,
double[] step,
Vector2D yprim)
Takes a tabulated function as an array of Vector2D and does cubic spline interpolation at all x-values given in the step array. |
static double |
diffraction(double x)
Bessel function J1(x)/x for any real x, also x=0. |
static long |
fac(int n)
Returns n!. |
static double |
frac(double val)
Returns the part of the double behind the point. |
static double |
gauss(double arg)
Returns the valus of the Gauss function. |
static double |
gauss(double arg,
double sigma)
Returns the valus of the Gauss function. |
static int |
greatestCommonFactor(int a,
int b)
Returns the greatest common factor using Euklid's algorithm. |
static Vector3D |
interpolateExtremum(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Parabolic extremum. |
static double |
interpolatingParabel(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double xd)
Parabolic interpolation. |
static VectorG |
interpolatingParabel(VectorG a1,
VectorG a2,
VectorG a3,
double xd)
Parabolic interpolation. |
static double |
j0(double x)
Bessel function J0 for any real x. |
static double |
j1(double x)
Bessel function J1 for any real x. |
static int |
leastCommonMultiple(int a,
int b)
Returns the least common multiple of two integers. |
static Vector2D[] |
linearSpline(Vector2D[] tab,
double[] step)
A linear spline is simply a linear interpolation between the borders of the tabulated values. |
static double |
lnFac(int n)
Estimates factorials with the gamma function estimate. |
static double |
log10(double a)
Decadic logarithm. |
static void |
main(String[] arg)
|
static double |
moffat(double alpha,
double beta,
double r)
The normalized Moffat function. |
static double |
moffatFwhm(double fwhm,
double beta,
double r)
The normalized Moffat function for beta and FWHM, with |
private static Vector3D |
parabolarFit(Vector2D v1,
Vector2D v2,
Vector2D v3,
double xd)
Returns the three parabolic constants a_i from |
static Number[] |
quadraticEquation(double a,
double b,
double c)
Solves a quadratic equation of form |
static double |
restrict(double x,
double min,
double max)
Confines the argument so that it is not less than the minimum and not bigger than the maximum. |
static int |
restrict(int x,
int min,
int max)
Confines the argument so that it is not less than the minimum and not bigger than the maximum. |
static long |
restrict(long x,
long min,
long max)
Confines the argument so that it is not less than the minimum and not bigger than the maximum. |
static double |
sign(double val)
Sign function returning +1 if the argument is positive or -1 if the argument is negative. |
static double |
simhoerl(double arg,
int n)
Returns the value of the Gauss function multiplied with x-1/n. |
static double |
sinh(double x)
Sinus hyperbolicus. |
private static Vector3D[] |
spline(Vector2D[] tab,
Vector2D yprim)
Does the spline coefficients for the second derivatives on the entire data set in one sweep. |
static double |
square(double x)
Square the argument. |
static double |
tanh(double x)
Tangens hyperbolicus. |
static double[] |
toHexArray(double val)
Converts a normal number like grad.fgrad to deg[0], min[1], sec[2] doubles. |
static double |
zeroBisection(Function f,
double xplus,
double xminus,
double acc,
int nmax)
Uses bisection to find a root of the Function f in the intervals with given accuracy. |
static double |
zeroNewton(Derivative f,
double xs)
Tries to find a zero point of the function using the starting value supplied. |
static double |
zeroNewton(Derivative f,
double xs,
double acc)
Tries to find a zero point of the function using the starting value supplied. |
static double |
zeroNewton(Derivative f,
double xs,
double acc,
int nmax)
Tries to find a zero point of the function using the starting value supplied. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final float FLOAT_NORM
public static final double DOUBLE_NORM
public static final String NAN
public static final char PM
public static final double LN10
public static final double LN2
public static final double LN2PI
public static final double SQRLN12
public static final double FWHM
public static final double SQR2
public static final double SQR3
public static final double ERRF1
public static final double STD2IQR
private static final int MAXNEWTON
private static final double ACCNEWTON
| Constructor Detail |
|---|
public Math2()
| Method Detail |
|---|
public static final double restrict(double x,
double min,
double max)
x - The value that should be confinedmin - The minimum allowed value.max - The maximum allowed value.
public static final long restrict(long x,
long min,
long max)
x - The value that should be confinedmin - The minimum allowed value.max - The maximum allowed value.
public static final int restrict(int x,
int min,
int max)
x - The value that should be confinedmin - The minimum allowed value.max - The maximum allowed value.
public static final double square(double x)
public static final double tanh(double x)
public static final double sinh(double x)
public static final double cosh(double x)
public static final double arsinh(double x)
public static final double arcosh(double x)
public static final double artanh(double x)
public static final double log10(double a)
public static double moffat(double alpha,
double beta,
double r)
(β-1)/πα²
psf(r)=(β-1)/πα²[1+(r/α)²]-β,Its integral for r=0->&infinity; equals 1.
public static double moffatFwhm(double fwhm,
double beta,
double r)
FWHM = 2α√(21/β-1). Normalized for area, i.e. the integral equals one. The value at r=0 has to be normalized by the value
4*(β-1)*(2^(1/β-1))/πFWHM²
public static final double j0(double x)
public static final double j1(double x)
public static final double diffraction(double x)
I=I0*(2.*J1(x)/x)^2, x = k · D/2 · sin(θ),
k=2π/λ
Numerical Recipes, p. 233
public static VectorG interpolatingParabel(VectorG a1,
VectorG a2,
VectorG a3,
double xd)
y_i = a0*(x-xd)ˆ2+a1*(x-xd)+a2is fitted to the the input points at the given three values and the y_i at xd is calculated and returned as a vector, whoses zero'th component is the interpolating point xd and the remaining indices are filled with the corresponding parabolic fit.
a1 - A cornerpoint where the functional value is knowna2 - A cornerpoint where the functional value is knowna3 - A cornerpoint where the functional value is knownxd - The parameter value to which we should interpolate.
public static double interpolatingParabel(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double xd)
y_i = a0*(x-xd)ˆ2+a1*(x-xd)+a2is fitted to the the input points at the given three values and the y_i at xd is calculated and returned.
x1 - A cornerpoint where the functional value is knowny1 - A cornerpoint where the functional value is knownx2 - A cornerpoint where the functional value is knowny2 - A cornerpoint where the functional value is knownx3 - A cornerpoint where the functional value is knowny3 - A cornerpoint where the functional value is knownxd - The parameter value to which we should interpolate.
public static Vector3D interpolateExtremum(double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
y_i=a0*(x-xd)^2+a1*(x-xd)+a2,
where y'(x)=0
Returned is the x/y value of the extremum of the parabel.
x1 - A cornerpoint where the functional value is knowny1 - A cornerpoint where the functional value is knownx2 - A cornerpoint where the functional value is knowny2 - A cornerpoint where the functional value is knownx3 - A cornerpoint where the functional value is knowny3 - A cornerpoint where the functional value is known
private static Vector3D parabolarFit(Vector2D v1,
Vector2D v2,
Vector2D v3,
double xd)
y_i = a0*(x-xd)ˆ2+a1*(x-xd)+a2as a three-dimensional vector with according indices.
public static final Vector2D[] cubicSpline(Vector2D[] tab,
double[] step,
Vector2D yprim)
tab - The tabulated function, ordered.step - Where the spline should be evaluated, order kept in output.bond - Boundary values of the first derivative, null for natural
spline.
public static final Vector2D[] linearSpline(Vector2D[] tab,
double[] step)
private static final Vector3D[] spline(Vector2D[] tab,
Vector2D yprim)
cubicSpline(vec_math.Vector2D[], double[], vec_math.Vector2D)
tab - The tabulated function, ordered.bond - Boundary values of the first derivative, null for natural
spline.
public static double confinePeriod(double arg,
double period)
arg - The valueperiod - Its periodconfine2PI(double),
confine360(double),
confine24h(double)public static double confine2PI(double arg)
arg - Angle in radians.confinePeriod(double, double)public static double confine360(double arg)
arg - Angle in degrees.confinePeriod(double, double)public static double confine24h(double arg)
arg - Angle in hours.confinePeriod(double, double)public static double sign(double val)
public static Number[] quadraticEquation(double a,
double b,
double c)
a·x²+b·x+c=0in real space, i.e. a,b,c are real numbers, not complex. The returned numbers, however, are either a pair of
Doubles or a pair of
Complex.
a - The factor to x².b - The factor to x.c - The constant.
Numbers.
public static Number[] cubicEquation(double a,
double b,
double c,
double d)
a·x³+b·x²+c·x+d=0in real space, i.e. a, b, c, and d are real numbers, not complex. The returned numbers, however, are either a
Double and a pair of
Complex, or three Doubles.
a - The factor to x³.b - The factor to x².c - The factor to x.d - The constant.
Numbers. First always Double.
public static double zeroNewton(Derivative f,
double xs)
f - the differntiable function where the root should be found.xs - Starting valueacc - Absoulte accuracy in the first derivative to be obtained.
public static double zeroNewton(Derivative f,
double xs,
double acc)
f - the differntiable function where the root should be found.xs - Starting valueacc - Absoulte accuracy in the first derivative to be obtained.
public static double zeroNewton(Derivative f,
double xs,
double acc,
int nmax)
f - the differntiable function where the root should be found.xs - Starting valueacc - Absoulte accuracy in the root improvement to be obtained.
public static double zeroBisection(Function f,
double xplus,
double xminus,
double acc,
int nmax)
½nmax*abs(xplus-xminus)
f - the function where the root should be found.xplus - Value, where f(xplus) > 0xminus - Value, where f(xminus) < 0.acc - The desired accuracy.nmax - Maximum number of iterations.
public static double gauss(double arg,
double sigma)
public static double gauss(double arg)
public static double simhoerl(double arg,
int n)
public static boolean contains(double[] arr,
double val)
public static boolean contains(Object[] arr,
Object val)
public static double frac(double val)
public static long fac(int n)
public static double lnFac(int n)
\ln \Gamma(z) \approx \frac{1}{2} \left(\ln(2 \pi) - \ln z \right) + z \left(\ln \left( z + \frac{1}{12z- \frac{1}{10z}} \right)-1\right).
public static int aoverb(int a,
int b)
public static int leastCommonMultiple(int a,
int b)
public static int greatestCommonFactor(int a,
int b)
public static double[] toHexArray(double val)
public static void main(String[] arg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||