A summary of the correlation functions of C-language _c language

Source: Internet
Author: User

C language Tan () function: tangent function
header file:

#include <math.h>

The tan () function is used to find the tangent of a given value, and its prototype is:

  Double tan (double x);

The "parameter" x is the given radian value.

Return value returns the tangent value of x.

Note that when compiling with GCC, please join-LM.

Take a look at the following code:

#include <math.h>
Main () {
  Double answer = tan (0.5);
  printf ("tan (0.5) =%f\n", answer);
}

Output results:

Tan (0.5) = 0.546302

C language Tanh () function: hyperbola tangent function
header file:

#include <math.h>

Tanh () is used to find the hyperbolic tangent of a number, and its prototype is:

  Double Tanh (double x);

"Parameter" x is a point on the hyperbolic tangent.

Return value returns the hyperbolic tangent of x, with a value ranging from 1 to 1.

The hyperbolic tangent is defined as Sinh (x)/cosh (x), i.e.

Diagram of hyperbolic tangent curve:

Note that when compiling with GCC, please join-LM.

Take a look at the following code:

#include <math.h>
Main () {
  Double answer = tanh (0.5);
  printf ("tanh (0.5) =%f\n", answer);
}

Output results:

Tanh (0.5) = 0.462117

C Language Atan () function: To calculate the tangent value (in radians)
header file:

#include <math.h>

To define a function:

Double Atan (double x);

Function Description: Atan () is used to calculate the inverse tangent value of the parameter x, and then returns the result.

Return value: Returns the result of the calculation between-PI/2 and PI/2.

Note that when compiling with GCC, please join-LM.

Example

#include <math.h>
Main () {
  double angle;
  Angle = Atan (1);
  printf ("angle =%f\n", angle);
}

Perform

Angle = 1.570796

C language atan2 () function: To calculate the tangent value (in radians)
header file:

#include <math.h>

To define a function:

Double atan2 (double y, double x);

Function Description: atan2 () is used to calculate the tangent value of the parameter y/x, and then returns the result.

Return value: Returns the result of the calculation between-PI/2 and PI/2.

Note that when compiling with GCC, please join-LM.

Example

#include <math.h>
Main () {
  double angle;
  Angle = atan2 (1, 2);
  printf ("angle =%f\n", angle);
}

Perform

Angle = 0.463648

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.