-
Notifications
You must be signed in to change notification settings - Fork 0
/
uv.cpp
228 lines (197 loc) · 5.24 KB
/
uv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include "header.h"
using namespace std;
bool uv_function(string equ)
{
for(int i=0; i<equ.size(); i++)
{
if(equ[i]=='*' && equ[i-1]==')' && (equ[i+1]=='(' || (equ[i+1] > 96 && equ[i+1] < 123)))
return true;
else
continue;
}
return false;
}
string if_uv(string equ)
{
string ans8 = "";
string d_f = "", d_s = "";
char first_uv[1000], second_uv[1000];
int for_delimit=0, j=0, k=0, sign_comp1, sing_comp1;
cout<<"\n\n\t\t"<<"This equation follows the UV method as it's a product of two functions."<<"\n\n\t\tWe know that -"
<<"\n\n\t\t\t"<<"d/dx(u*v) = u*d/dx(v) + v*d/dx(u)"<<"\n\n\t\t"<<"Here-\n\n\t\t\t";
for(int i=0; i<equ.size(); i++)
{
if (equ[i] == '*' && equ[i-1] == ')' && (equ[i+1] == '(' || (equ[i+1] >96 && equ[i+1] <123)))
{
for_delimit = 1;
continue;
}
if(for_delimit==0)
{
first_uv[i] = equ[i];
k++;
}
else if(for_delimit==1)
{
second_uv[j] = equ[i];
j++;
}
}
first_uv[k] = '\0';
second_uv[j] = '\0';
cout<<"u = "<<first_uv<<"\n\n\t\t\t";
cout<<"v = "<<second_uv<<"\n\n\t\t\n\t\t";
bool trigonometry_tracker2 = trigonometry_function(second_uv);
bool ln_tracker2 = ln_function(second_uv);
bool root_tracker2 = root_function(second_uv);
bool exp_tracker2 = exp_function(second_uv);
if(trigonometry_tracker2==true)
{
sing_comp1 = trigono_sign();
if(sing_comp1==2 || sing_comp1==3 || sing_comp1==6)
{
if(if_trigonometry(second_uv)!="0")
ans8 += "-";
}
}
if(trigonometry_tracker2==true)
{
if(sing_comp1==2 || sing_comp1==3 || sing_comp1==6)
{
if(if_trigonometry(second_uv)!="0")
d_s += "-";
}
string s = if_trigonometry(second_uv);
if(s!="0")
{
ans8 += first_uv;
ans8 += "*";
ans8 += s;
}
d_s += s;
}
else if(ln_tracker2==true)
{
if(if_ln(second_uv)!="0")
{
ans8 += first_uv;
ans8 += "*";
ans8 += if_ln(second_uv);
}
d_s += if_ln(second_uv);
}
else if(root_tracker2==true)
{
if(if_root(second_uv)!="0")
{
ans8 += first_uv;
ans8 += "*";
ans8 += if_root(second_uv);
}
d_s += if_root(second_uv);
}
else if(exp_tracker2==true)
{
if(if_exp(second_uv)!="0")
{
ans8 += first_uv;
ans8 += "*";
ans8 += if_exp(second_uv);
}
d_s += if_exp(second_uv);
}
else
{
string s3 = "(";
s3 += for_partition(second_uv);
if(s3!="(0)")
{
ans8 += first_uv;
ans8 += "*";
ans8 += s3;
}
d_s += s3;
}
bool trigonometry_tracker3 = trigonometry_function(first_uv);
bool ln_tracker3 = ln_function(first_uv);
bool root_tracker3 = root_function(first_uv);
bool exp_tracker3 = exp_function(first_uv);
if(trigonometry_tracker3==true)
{
sign_comp1 = trigono_sign();
if(sign_comp1==2 || sign_comp1==3 || sign_comp1==6)
ans8 += "-";
else
ans8 += "+";
}
else
ans8 += "+";
if(trigonometry_tracker3==true)
{
if(sign_comp1==2 || sign_comp1==3 || sign_comp1==6)
{
if(if_trigonometry(first_uv)!="0")
d_f += "-";
}
string s1 = if_trigonometry(first_uv);
if(s1!="0")
{
ans8 += second_uv;
ans8 += "*";
ans8 += s1;
}
d_f += s1;
}
else if(ln_tracker3==true)
{
if(if_ln(first_uv)!="0")
{
ans8 += second_uv;
ans8 += "*";
ans8 += if_ln(first_uv);
}
d_f += if_ln(first_uv);
}
else if(root_tracker3==true)
{
if(if_root(first_uv)!="0")
{
ans8 += second_uv;
ans8 += "*";
ans8 += if_root(first_uv);
}
d_f += if_root(first_uv);
}
else if(exp_tracker3==true)
{
if(if_exp(first_uv)!="0")
{
ans8 += second_uv;
ans8 += "*";
ans8 += if_exp(first_uv);
}
d_f += if_exp(first_uv);
}
else
{
string s2 = "(";
s2 += for_partition(first_uv);
if(s2!="(0)")
{
ans8 += second_uv;
ans8 += "*";
ans8 += s2;
}
d_f += s2;
}
cout<<"d/dx(u) = d/dx "<<first_uv<<"\n\n\t\t\t= ";
for(int i=0; i<d_f.size(); i++)
cout<<d_f[i];
cout<<"\n\n\t\t"<<"d/dx(v) = d/dx "<<second_uv<<"\n\n\t\t\t= ";
for(int i=0; i<d_s.size(); i++)
cout<<d_s[i];
cout<<"\n\n\t\tSo-\n\n\t\t\td/dx(u*v) = u*d/dx(v)+v*d/dx(u)\n\n\t\t\t\t = ";
d_f = "";
d_s = "";
return ans8;
}