[Algorithm] Calculate the trigonometric functions

The formula for calculating the sine(x) and the other trigonometric functions as follows:

trigonometric

VD calculate sine(x) , x per radian

#include <stdio.h>
#include <stdlib.h>
int main()
{
	double sinx, temp, x;	// x tinh theo radian
	int i = 0;
	scanf("%lf", &x);
	sinx = temp = x;
	while (temp > 0.000001 || temp < -0.000001)	// lam tron den 5 so thap phan
	{
		i++;
		temp = temp*x/(2*i+1)*x/(2*i);	// x^(2i+1)/(2i+1)!
		if (i%2==0) sinx = sinx + temp;
		else sinx = sinx - temp;
	}
	
	printf("%.5f",sinx);
	return 0;
}

Perhaps because of the type of data or some other reason that only accurate up to -27<=x<With x = 27 per radian.
In the code above we do not count the function x ^(2i 1) and (2i 1)! apart which means continuity in temp temp = x ^ calculation(2i 1) / (2i 1)! to avoid overflow of the large number of x.

From here we can build the calculation for the other trigonometric functions.

Refer to:
Trigonometric functions