📄 math.h
字号:
printf("beta(%f, %f) = %f\n", a, b, val);
}
*/
double beta( double a, double b );
/** >Mathematical
computes the incomplete gamma function.
Parameters:
x, a are standard arguments of incomplete gamma function
Returns:
incomplete gamma function of x, a
Example:
void run_incgamma()
{
double a = 2, x = .5;
double val = incgamma(x, a);
printf("incgamma(%f, %f) = %f\n", x, a, val);
}
*/
double incgamma( double x, double a );
/** >Mathematical
Compute the Bessel function of the first kind of order n.
Parameters:
x = independent variable
n = order
Returns:
Jn(x)
Example:
void run_Jn()
{
double x = 4.;
int n = 2;
double val = Jn(x, n);
printf("Jn(%f, %d) = %f\n", x, n, val);
}
*/
double Jn( double x, int n );
/** >Mathematical
Compute the Bessel function of the first kind of order 0.
Parameters:
x = independent variable
Returns:
J0(x)
Example:
void run_J0()
{
double x = 4.;
double val = J0(x);
printf("J0(%f) = %f\n", x, val);
}
*/
double J0( double x );
/** >Mathematical
Compute the Bessel function of the first kind of order 1.
Parameters:
x = independent variable
Returns:
J1(x)
Example:
void run_J1()
{
double x = 4.;
double val = J1(x);
printf("J1(%f) = %f\n", x, val);
}
*/
double J1( double x );
/** >Mathematical
Compute the Bessel function of the second kind of order n.
Parameters:
x = independent variable
n = order
Returns:
Yn(x)
Example:
void run_Yn()
{
double x = 4.;
int n = 2;
double val = Yn(x, n);
printf("Yn(%f, %d) = %f\n", x, n, val);
}
*/
double Yn( double x, int n);
/** >Mathematical
Compute the Bessel function of the second kind of order 0.
Parameters:
x = independent variable
Returns:
Y0(x)
Example:
void run_Y0()
{
double x = 4.;
double val = Y0(x);
printf("Y0(%f) = %f\n", x, val);
}
*/
double Y0( double x );
/** >Mathematical
Compute the Bessel function of the second kind of order 1.
Parameters:
x = independent variable
Returns:
Y1(x)
Example:
void run_Y1()
{
double x = 4.;
double val = Y1(x);
printf("Y1(%f) = %f\n", x, val);
}
*/
double Y1( double x );
/** >Mathematical
Calculate the arccosine.
Paramaters:
x = independent variable
Returns:
acos(x)
Example:
void run_acos()
{
double x = -1.;
double val = acos(x);
printf("acos(%f) = %f\n", x, val);
}
*/
double acos(double x);
/** >Mathematical
Calculate the arcsine.
Paramaters:
x = independent variable
Returns:
asin(x)
Example:
void run_asin()
{
double x = -1.;
double val = asin(x);
printf("asin(%f) = %f\n", x, val);
}
*/
double asin(double x);
/** >Mathematical
Calculate the exponential (the base of natural logarithm to the power x)
Paramaters:
x = independent variable
Returns:
exp(x)
Example:
void run_exp()
{
double rExp = 2.;
double val = exp(rExp);
printf("exp(%f) = %f\n", rExp, val);
}
*/
double exp(double x);
/** >Mathematical
Natural logarithm.
Parameters:
x = independent variable
Returns:
log(x)
Example:
void run_log()
{
double x = 7.389056;
double val = log(x);
printf("log(%f) = %f\n", x, val);
}
SeeAlso:
ln, log10
*/
double log(double x);
/** >Mathematical
Natural logarithm, same as log(x)
Parameters:
x = independent variable
Returns:
ln(x)
Example:
void run_ln()
{
double x = 123.;
double val = ln(x);
printf("ln(%f) = %f\n", x, val);
}
SeeAlso:
log, log10
*/
double ln(double x);
/** >Mathematical
logarithm of base 10
Parameters:
x = independent variable
Returns:
log10(x)
Example:
void run_log10()
{
double x = 10000.;
double val = log10(x);
printf("log10(%f) = %f\n", x, val);
}
SeeAlso:
ln, log
*/
double log10(double x); // log base 10; see log or ln functions for log base e
/** >Mathematical
Calculates the square root.
Parameters:
x = independent variable
Returns:
square root of x
Example:
void run_sqrt()
{
double rr = 625;
double val = sqrt(rr);
printf("sqrt(%f) = %f\n", rr, val);
}
*/
double sqrt(double x);
/** >Mathematical
Calculates the hypotenuse (the longest side) of a right triangle given
the two sides of the right angle
Parameters:
x, y = two sides of the right angle of a right triangle
Returns:
hypotenuse
Examples:
void run_hypot()
{
double x = 3., y = 4.;
double val = _hypot(x, y);
printf("_hypot(%f, %f) = %f\n", x, y, val); // the result should be 5.
}
*/
double _hypot(double x, double y);
// the following functions will leading to INF.
/** >Mathematical
Calculates hyperbolic cosine.
Paramaters:
x = independent variable
Returns:
cosh(x)
Example:
void run_cosh()
{
double x = 2.;
double val = cosh(x);
printf("cosh(%f) = %f\n", x, val);
}
*/
double cosh(double x);
/** >Mathematical
Calculates hyperbolic sine.
Paramaters:
x = independent variable
Returns:
sinh(x)
Example:
void run_sinh()
{
double x = 2.;
double val = sinh(x);
printf("sinh(%f) = %f\n", x, val);
}
*/
double sinh(double x);
/** >Mathematical
Absolute value of a floating-point (double).
Paramaters:
x=Input value whose absolute value is returned
Return:
Returns the absolute value of x.
Example:
void run_fabs()
{
double x = -5.9;
double val = fabs(x);
printf("fabs(%f) = %f\n", x, val);
}
SeeAlso:
abs
*/
double fabs(double x);
/** >Mathematical
Calculates the trigonometric tangent.
Paramaters:
x = independent variable
Returns:
tan(x)
Example:
void run_tan()
{
double x = 0.78;
double val = tan(x);
printf("tan(%f) = %f\n", x, val);
}
*/
double tan(double x);
/** >Mathematical
Calculates the double value corresponding to the smallest integer
that is greater than or equal to x.
Paramaters:
x = independent variable
Returns:
ceil(x)
Example:
void run_ceil()
{
double x1 = -4.6, x2 = 4.6;
printf("ceil(%f) = %f\nceil(%f) = %f\n", x1, ceil(x1), x2, ceil(x2));
}
*/
double ceil( double x );
/** >Mathematical
Calculates the double value corresponding to the largest integer
that is less than or equal to x.
Paramaters:
x = independent variable
Returns:
floor(x)
Example:
void run_floor()
{
double x1 = -4.6, x2 = 4.6;
printf("floor(%f) = %f\nfloor(%f) = %f\n", x1, floor(x1), x2, floor(x2));
}
*/
double floor( double x );
/** >Mathematical
compare two double values and see if they are equal or not equal in the
same sense as in LabTalk.
This function uses the LabTalk system variable @ND to test if
(abs(x)-abs(y))/((abs(x)+abs(y))
is less then @ND or not. If @ND = 0, it does standard arithmetic comparison x == y.
Parameters:
nCode = '=' for testing for equality; any other value will test for inequality.
Example:
void run_is_equal()
{
double a = 1.;
// add 1.e-17:
a += 1.e-17;
// Compare with 1.:
if (is_equal(a, 1.))
{
// If @ND still has the default value, which is 1.e-16, this will be true.
out_str("a is 1.");
}
else
{
out_str("a is not 1.");
}
// add 1.e-14
a += 1.e-14;
if (is_equal(a, 1.))
{
// If @ND still has the default value, which is 1.e-16, this will be false.
out_str("a is 1.");
}
else
{
out_str("a is not 1.");
}
}
*/
BOOL is_equal(double x, double y, int nCode='=');
// the following are from Ok70.dll
#pragma dll(@OK)
/** >Mathematical
Calculates a double value which is equal to x up to nSignificantDigits significant digits
Parameter:
x = independent variable
Returns:
x with the precision of nSignificantDigits significant digits.
Example:
void run_prec()
{
double x = 34.56789;
int nSignificantDigits = 5;
printf("prec(%f, %d) = %f", x, nSignificantDigits, prec(x, nSignificantDigits));
}
*/
double prec(double x, int nSignificantDigits);
/** >Mathematical
Calculates a double value which is equal to x up to nDecimalPlaces decimal places
Parameter:
x = independent variable
Returns:
x with nDecimalPlaces decimal places.
Example:
void run_round()
{
double x = 34.56789;
int nDecimalPlaces = 3;
printf("round(%f, %d) = %f", x, nDecimalPlaces, round(x, nDecimalPlaces));
}
*/
double round( double x, int nDecimalPlaces ); // force given value to be nDecimalPlaces
/** >Mathematical
Test given string to determine whether it is a numeric string
Parameters:
lpcstr = the alpha numeric string to test
bThousoudSeparatorOK = to decide if thousand's separator can be used, like 1,234,567
bLeadZeroOK = to decide if 01060 is a number (TRUE) or it should be considered not a number (bLeadZeroOK=FALSE)
Return:
TRUE if given string is numeric, otherwise FALSE.
Example:
double convert_str_to_num(string str)
{
if (is_numeric(str))
return atof(str);
else
return NANUM;
}
*/
BOOL is_numeric(LPCSTR lpcstr, BOOL bThousoudSeparatorOK = TRUE, BOOL bLeadZeroOK = TRUE);
#include <msmath.h>
#endif //_MATH_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -