> ~ Online tutorial


Mathematical Functions
C has a library of standard mathematical functions which can be accessed by #including the appropriate header files (math.h etc.). It should be noted that all of these functions work with double or long float type variables. All of C's mathematical capabilities are written for long variable types. Here is a list of the functions which can be expected in the standard library file. The variables used are all to be declared long
int i;                   /* long int */
double x,y,result;       /* long float */

The functions themselves must be declared long float or double (which might be done automatically in the mathematics library file, or in a separate file) and any constants must be written in floating point form: for instance, write 7.0 instead of just 7.

ABS()
MACRO. Returns the unsigned value of the value in parentheses. See fabs() for a function version.
fabs()
Find the absolute or unsigned value of the value in parentheses:
 result = fabs(x);


ceil()
Find out what the ceiling integer is: that is, the integer which is just above the value in parentheses. This is like rounding up.
 i = ceil(x);

 /* ceil (2.2) is 3 */


floor()
Find out what the floor integer is: that is, the integer which is just below the floating point value in parentheses
 i = floor(x);

 /* floor(2.2) is 2 */


exp()
Find the exponential value.
 result = exp(x);
 result = exp(2.7);


log()
Find the natural (Naperian) logarithm. The value used in the parentheses must be unsigned: that is, it must be greater than zero. It does not have to be declared specifically as unsigned. e.g.
 result = log(x);
 result = log(2.71828);


log10()
Find the base 10 logarithm. The value used in the parentheses must be unsigned: that is, it must be greater than zero. It does not have to be declared specifically as unsigned.
 result = log10(x);
 result = log10(10000);


pow()
Raise a number to the power.
 result = pow(x,y); /*raise x to the power y */
 result = pow(x,2); /*find x-squared */

 result = pow(2.0,3.2); /* find 2 to the power 3.2 ...*/

sqrt()
Find the square root of a number.
 result = sqrt(x);
 result = sqrt(2.0);


sin()
Find the sine of the angle in radians.
 result = sin(x);
 result = sin(3.14);


cos()
Find the cosine of the angle in radians.
 result = cos(x);
 result = cos(3.14);


tan()
Find the tangent of the angle in radians.
 result = tan(x);
 result = tan(3.14);


asin()
Find the arcsine or inverse sine of the value which must lie between +1.0 and -1.0.
 result = asin(x);
 result = asin(1.0);


acos()
Find the arccosine or inverse cosine of the value which must lie between +1.0 and -1.0.
 result = acos(x);
 result = acos(1.0);


atan()
Find the arctangent or inverse tangent of the value.
 result = atan(x);
 result = atan(200.0);


atan2()
This is a special inverse tangent function for calculating the inverse tangent of x divided by y. This function is set up to find this result more accurately than atan().
 result = atan2(x,y);
 result = atan2(x/3.14);


sinh()
Find the hyperbolic sine of the value. (Pronounced "shine" or "sinch")
 result = sinh(x);
 result = sinh(5.0);


cosh()
Find the hyperbolic cosine of the value.
 result = cosh(x);
 result = cosh(5.0);


tanh()
Find the hyperbolic tangent of the value.
 result = tanh(x);
 result = tanh(5.0);

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: