all trigonometric functions with complex numbers in c 2fc 2b 2b

Solutions on MaxInterview for all trigonometric functions with complex numbers in c 2fc 2b 2b by the best coders in the world

showing results for - "all trigonometric functions with complex numbers in c 2fc 2b 2b"
Camilo
07 May 2018
1#include "stdafx.h"
2#include "calc.h"
3
4
5double INF = DBL_MAX;
6double mINF = INF * -1;
7
8void cotan(double x, double y) {
9	resultR = 0; resultI = 0;
10	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
11		complex_tan(x, y);
12		division(1.0, 0.0, resultR, resultI);
13	}
14	else {
15		if (rasf > 0) {
16			printf("\nError in function domain.\n\n ==> For cotangent function the valid domain is {x| x != 0 + kpi, k = ..., -1, 0, 1, ...}  \n\n");
17			printf(" ==> Your function argument: ");
18			complexNumber(x, y);
19		}
20	}
21}
22
23void sec(double x, double y) {
24	resultR = 0; resultI = 0;
25	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
26		complex_cos(x, y);
27		division(1.0, 0.0, resultR, resultI);
28	}
29	else {
30		if (rasf > 0) {
31			printf("\nError in function domain.\n\n ==> For secant function the valid domain is {x| x != pi/2 + kpi, k = ..., -1, 0, 1, ...}  \n\n");
32			printf(" ==> Your function argument: ");
33			complexNumber(x, y);
34		}
35	}
36}
37
38void cosec(double x, double y) {
39	resultR = 0; resultI = 0;
40	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
41		complex_sin(x, y);
42		division(1.0, 0.0, resultR, resultI);
43	}
44	else {
45		if (rasf > 0) {
46			printf("\nError in function domain.\n\n ==> For cosecant function the valid domain is {x| x != 0 + kpi, k = ..., -1, 0, 1, ...}  \n\n");
47			printf(" ==> Your function argument: ");
48			complexNumber(x, y);
49		}
50	}
51}
52
53void arcosec(double x, double y) {
54	resultR = 0; resultI = 0;
55	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
56		division(1.0, 0.0, x, y);
57		complex_asin(resultR, resultI);
58	}
59	else {
60		if (rasf > 0) {
61			printf("\nError in function domain.\n\n ==> For arc cosecant function the valid domain is [-INF, INF] ^ != [-1, 1].\n\n");
62			printf(" ==> Your function argument: ");
63			complexNumber(x, y);
64		}
65	}
66}
67
68void arcsec(double x, double y) {
69	resultR = 0; resultI = 0;
70	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
71		division(1.0, 0.0, x, y);
72		complex_acos(resultR, resultI);
73	}
74	else {
75		if (rasf > 0) {
76			printf("\nError in function domain.\n\n ==> For arc secant function the valid domain is ]-INF, INF[ ^ != [-1, 1].\n\n");
77			printf(" ==> Your function argument: ");
78			complexNumber(x, y);
79		}
80	}
81}
82
83void arcotg(double x, double y) {
84	resultR = 0; resultI = 0;
85	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
86		division(1.0, 0.0, x, y);
87		complex_atan(resultR, resultI);
88	}
89	else {
90		if (rasf > 0) {
91			printf("\nError in function domain.\n\n ==> For arc cotangent function the valid domain is [-INF, INF].\n\n");
92			printf(" ==> Your function argument: ");
93			complexNumber(x, y);
94		}
95	}
96}
97
98void complex_cos(double x, double y) {
99	resultR = 0; resultI = 0;
100	if (x >= mINF && x <= INF && y >= mINF && y <= INF) {
101		exponentiation(M_E, 0.0, -1 * y, x, 1);
102		double napR = resultR, napI = resultI;
103		exponentiation(M_E, 0.0, y, -1 * x, 1);
104		double nap2R = resultR, nap2I = resultI;
105		sum(napR, napI, nap2R, nap2I);
106		double sumR = resultR, sumI = resultI;
107		division(sumR, sumI, 2.0, 0.0);
108	}
109	else {
110		if (rasf > 0) {
111			printf("\nError in function domain.\n\n ==> For cosine function the valid domain is [-INF, INF].\n\n");
112			printf(" ==> Your function argument: ");
113			complexNumber(x, y);
114		}
115	}
116}