- ..clause 1..: Absolute value
- ..clause 2..: Involution
- ..clause 3..: Square root(√)
- ..clause 4..: Trigonometric
Use the abs function to calculate the absolute value.
The usage of the abs function is as follows.
[ Absolute value ]
Distance on [sen] number ..repaired.. from starting point.
In short, a positive value is a numerical value that exactly does a negative as it is value.
The following program is an example of requesting the absolute value.絶対値 = abs(数値);
The execution result of this program becomes as follows.#include <stdio.h> #include <stdlib.h> void main(void) { printf("%d\n",abs(10)); printf("%d\n",abs(-10)); return; }
10
10
Use the pow function to calculate the involution.
# include < math.h > is necessary to use the pow function.
The usage of the pow function is as follows.
It becomes inaccurate if it memorizes it by the int type because the value becomes double type.
The following program is an example of requesting the involution.累乗 = pow(数値,指数);
The execution result of this program becomes as follows.#include <stdio.h> #include <math.h> void main(void) { Printf ("%d multiplication = %f\n of %d" 5, 2, and pow(5,2)); Printf ("%d multiplication = %f\n of %d" 8, 3, and pow(8,3)); Printf ("%d multiplication = %f\n of %d" 2, 10, and pow(2,10)); return; }
The second power = of five 25.000000
The third power = of eight 512.000000
The tenth power = of two 1024.000000
Use the sqrt function to calculate a square root.
The usage of the sqrt function is as follows.
[ Square root ]
Numerical value that becomes number when doing by the second power.
When former numerical value is assumed to be an area of a square, the square root hits near length.
The following program is an example of requesting the square root.平方根 = sqrt(数値);
The execution result of this program becomes as follows.#include <stdio.h> #include <math.h> void main(void) { printf("√%d = %f : %f * %f = %f\n",100,sqrt(100),sqrt(100),sqrt(100),sqrt(100) * sqrt(100)); printf("√%d = %f : %f * %f = %f\n",2,sqrt(2),sqrt(2),sqrt(2),sqrt(2) * sqrt(2)); return; }
Though it seems to be computable accurately because it is rounded off
√100 = 10.000000 : 10.000000 * 10.000000 = 100.000000
√2 = 1.414214 : 1.414214 * 1.414214 = 2.000000
Use the following function to calculate trigonometric.
# include < math.h > is necessary to use these functions.
| Function name | Trigonometric value |
|---|---|
| sin | Signature |
| cos | Cosine |
| tan | Tangent |
| asin | Arc signature |
| acos | Arc cosine |
| atan | Arc tangent |
It explains both of the usage of these functions as an example of the tan function thereafter because it is the same.
[ Arc trigonometric system ]
The arc trigonometric the system does a usual, trigonometric reverse-calculation.
Though usual trigonometric requests a near ratio of length from the angle
The arc trigonometric the system requests the angle from a near ratio of length.
However, this angle is not an angle where 90 degrees that we usually use become right-angled.タンジェント = tan(ラジアン角度);
Radian =(times * 3.14159/ 180)
Doing this calculation every time makes the following macros because it is troublesome.
[ Radian ]
The circular arc is length of the radius and a unit of the angle of which one radian is the position becomes equal.
Use the radian in the world of computer in case of almost.
When looking up at the tree from a position 5m away of the person of the height 160cm, the following program :.#define RADIAN(ARC) ((ARC) * 3.14159 / 180)
The execution result of this program becomes as follows.#include <stdio.h> #include <math.h> #define RADIAN(ARC) ((ARC) * 3.14159 / 180) void main(void) { double stature = 160; double distance = 500; double arc = 40; double tree; tree = distance * tan(RADIAN(arc)) + stature; printf("%fm\n",tree / 100); return; }
When trigonometric repeats the calculation, ..error margin.. [derutame] attention is necessary.
5.795493m