Current location - Training Enrollment Network - Mathematics courses - How to Write Mathematical Formulas in C Language
How to Write Mathematical Formulas in C Language
1 and C have mathematical functions commonly used in the field, and the function libraries are math.h and stdlib.h.

Function name and explanation:

Int abs(int i) returns the absolute value of integer parameter i.

Double cabs(struct complex znum) returns the absolute value of complex znum.

Double fabs(double x) returns the absolute value of the double-precision parameter x.

Long labs(long n) returns the absolute value of the long integer parameter n.

Double e xp(double x) returns the value of the exponential function ex.

Doublefrexp (double value, int * eptr) returns the value of x in value=x*2n, where n is stored in eptr.

double ldexp(double value,int exp); Returns the value of value*2exp.

Double log(double x) returns the value of logex.

Double log 10 (double x) returns the value of log 10x.

Double pow(double x, double y) returns the value of xy.

Double pow 10(int p) returns the value of 10p.

Double sqrt(double x) returns the value of+√ x.

Doublecacos (doublex) returns the cosine of x, cos- 1(x), where x is radian.

Doublesin (doublex) returns the sine of x- 1 (x), where x is radian.

Double atan(double x) returns the arc tangent tan- 1(x) value of x, where x is radian.

Double atan2(double y, double x) returns the arc tangent tan- 1(x) value of y/x, where x of y is radian.

Double cos(double x) returns the cosine cos(x) value of x, where x is radian.

Double sin(double x) returns the sine sin(x) value of x, where x is radian.

Double tan(double x) returns the tangent tan(x) value of x, where x is radian.

Double cosh(double x) returns the hyperbolic cosine of x, where x is radian.

Double sinh(double x) returns the hyperbolic sine sinh(x) value of x, where x is radian.

Double tanh(double x) returns the hyperbolic tangent tanh(x) value of x, where x is radian.

Double hypot(double x, double y) returns the length (z) of the hypotenuse of a right triangle, where x and y are the lengths of the right side, and z2=x2+y2.

2. Complex mathematical functions can be realized in the form of user-defined functions.

For example:

Double? ConerVelocity(int? First,? Double? x 1,? Double? y 1,? Double? x2,? Double? y2,? Double? t 1,? Double? t2)

{

Double? t,V;

T=acos(abs(x 1? *? x2? +? y 1? *? y2)/? sqrt(x 1? *? x 1? +y 1? *? y 1)/sqrt(x2? *? x2? +y2? *? y2));

V=? (A? *? (T2-T 1))/(2 * sin(T/2));

Return? Five;

}