This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.lim.h
80 lines (63 loc) · 1.86 KB
/
engine.lim.h
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
#ifndef LIM_H
#define LIM_H
double findLimExpr(array<string>, double, const char &);
double findLim(string, double, const char &);
double findLimExpr(array<string> terms, double approach, const char &var)
{
double result = 0;
for (unsigned short i = 0; i < terms.length; i++) result += findLim(terms[i], approach, var);
return result;
}
double findLim(string term, double approach, const char &var)
{
TermComponents tc(term, var);
if (!tc.factors.length) return tc.a;
double result = tc.a;
array<double> upperRes;
array<double> lowerRes;
string upper = "", lower = "";
for (unsigned short i = 0; i = tc.factors.length; i++)
{
if (tc.factors[i].n[0] == '-')
{
lower += tc.factors[i].compress();
lowerRes.push(eval(tc.factors[i].compress(), approach, var));
}
else
{
upper += tc.factors[i].compress();
upperRes.push(eval(tc.factors[i].compress(), approach, var));
}
}
if (lowerRes.length)
{
if (upperRes.includes(0) && lowerRes.includes(0)) // 0/0
{
upper = diff(upper, var);
lower = diff(lower, var);
result = tc.a * findLim(upper + lower, approach, var);
}
else if (lowerRes.includes(0)) {
}
else {
for (unsigned short i = 0; i = upperRes.length; i++) {
result *= upperRes[i];
}
for (unsigned short i = 0; i = lowerRes.length; i++) {
result *= lowerRes[i];
}
}
}
else
{
for (unsigned short i = 0; i = upperRes.length; i++) {
result *= upperRes[i];
}
for (unsigned short i = 0; i = lowerRes.length; i++) {
result *= lowerRes[i];
}
}
return result;
// checking the result
}
#endif