C language cos () function: Cosine value
header file:
The Cos () function is used to find the cosine value, that is, the ratio of the side length of the angle to the length of the hypotenuse, and the prototype is:
The "parameter" x is a radian.
Return value returns the calculated result from 1 through 1.
The relationship between radians and angles is:
radians = 180/π angle
Angle =π/180 radians
Use the Rtod () function to convert radian values to angle values.
Note that when compiling with GCC, please join-LM.
"instance" asks for the cosine of two angles and outputs,
#include <stdio.h>
#include <math.h>
int main (void)
{
double angl,result;
Angl = 1;
result = cos (ANGL),/* Cosine value/
printf ("cos (%LF) is%lf\n", angl,result);/* Formatted output/
Angl = 3.1415926;
result = cos (ANGL)/* Cosine//
printf ("cos (%LF) is%lf\n", angl,result);/* formatted output/return
0;
}
Run Result:
Cos (1.000000) is 0.540302
cos (3.141593) is-1.000000
The parameters in the program are the Radian values that are used directly, and if you only know the angle, you can use the angle multiplied by the π/180 method to get the Radian value.
C language Cosh () function: To find hyperbolic residual Xuan value
header file:
Cosh () is used to compute the hyperbolic residual value of the parameter x, and then returns the result. Its prototype is:
The mathematical definition of hyperbolic cosine is:
That
Note that when compiling with GCC, please join-LM.
Hyperbolic cosine is a function image on the interval-5 <= x <= 5.
The "instance" asks for a hyperbolic cosine of 0.5.
#include <math.h>
Main () {
Double answer = cosh (0.5);
printf ("cosh (0.5) =%f\n", answer);
}
Run Result:
Another example is to find the value of a point on the hyperbolic cosine.
#include <stdio.h>
#include <math.h>
int main (void)
{
double resut;
Double x =1;
Resut = cosh (x);/* Seek hyperbolic cosine
/printf ("cosh (%LF) =%lf\n", x,resut);/* formatted output/return
0;
}
Run Result:
Cosh (1.000000) = 1.543081
The program first defines two double variables, Resut saves the computed result, and X provides the hyperbolic cosine function point. The function of the statement resut = cosh (x) is to find the value corresponding to the X point on the function and assign the result to the Resut.
C language ACOs () function: To find the value of the inverse cosine
header file:
The ACOs () function returns an inverse cosine, in radians, whose prototype is:
The parameter x is the cosine value, ranging from 1 to 1, and exceeding this range will cause an error and set the errno value to EDOM.
Return value returns the result of the calculation between 0 and π, in radians, and in radians in the function library.
The relationship between radians and angles is:
radians = 180/π angle
Angle =π/180 radians
Note: Please join-LM when compiling with GCC.
The "instance" asks for a 0.5 inverse cosine.
#include <math.h>
Main () {
double angle;
Angle = ACOs (0.5);
printf ("angle =%f\n", angle);
}
Run Result:
For example, the cosine value is the corresponding angle.
#include <stdio.h>
#include <math.h>
int main (void)
{
double angl,result;
Angl = 1;
Result =acos (cos (ANGL))//* negation cosine/
printf ("ACOs (%LF) is%lf\n", cos (ANGL), result);/* Formatted output/
Angl = 3.1415926;
result = ACOs (cos (ANGL)),/* negation cosine/
printf ("ACOs (%LF) is%lf\n", cos (ANGL), result);/* formatted output/return
0;
}
Run Result:
ACOs (0.540302) is 1.000000
ACOs ( -1.000000) is 3.141593
This example can be learned from the cosine function example, where the cosine is used as the parameter and then the ACOs () function is used to find the angle for comparison.