25 lines
634 B
C
25 lines
634 B
C
|
#include <stdio.h>
|
||
|
#include <math.h>
|
||
|
|
||
|
// z_1 = cos(3pi / 8 - alpha / 4)^2 - cos(11pi / 8 + alpha / 4)^2
|
||
|
// z_2 = sqrt(2) / 2 * sin(alpha / 2)
|
||
|
|
||
|
int main() {
|
||
|
double alpha = 0, z_1 = 0, z_2 = 0;
|
||
|
|
||
|
printf("Input Ɑ: ");
|
||
|
|
||
|
if (scanf("%lf", &alpha) != 1){
|
||
|
printf("\e[1;31m[ERROR] Alpha must be a double, restart the program.\n\e[0m");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
z_1 = cos(3 * M_PI / 8 - alpha / 4) * cos(3 * M_PI / 8 - alpha / 4) - cos(11 * M_PI / 8 + alpha / 4) * cos(11 * M_PI / 8 + alpha / 4);
|
||
|
z_2 = sqrt(2) / 2 * sin(alpha / 2);
|
||
|
|
||
|
printf("z_1 = %lf\n", z_1);
|
||
|
printf("z_2 = %lf\n", z_2);
|
||
|
|
||
|
return 0;
|
||
|
}
|