mathai 0.5.2__tar.gz → 0.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {mathai-0.5.2 → mathai-0.5.4}/PKG-INFO +1 -1
  2. {mathai-0.5.2 → mathai-0.5.4}/mathai/__init__.py +1 -1
  3. {mathai-0.5.2 → mathai-0.5.4}/mathai/base.py +3 -1
  4. {mathai-0.5.2 → mathai-0.5.4}/mathai/integrate.py +15 -3
  5. mathai-0.5.4/mathai/limit.py +156 -0
  6. {mathai-0.5.2 → mathai-0.5.4}/mathai/parser.py +2 -2
  7. {mathai-0.5.2 → mathai-0.5.4}/mathai/simplify.py +5 -0
  8. {mathai-0.5.2 → mathai-0.5.4}/mathai.egg-info/PKG-INFO +1 -1
  9. {mathai-0.5.2 → mathai-0.5.4}/setup.py +1 -1
  10. mathai-0.5.2/mathai/limit.py +0 -132
  11. {mathai-0.5.2 → mathai-0.5.4}/README.md +0 -0
  12. {mathai-0.5.2 → mathai-0.5.4}/mathai/apart.py +0 -0
  13. {mathai-0.5.2 → mathai-0.5.4}/mathai/bivariate_inequality.py +0 -0
  14. {mathai-0.5.2 → mathai-0.5.4}/mathai/console.py +0 -0
  15. {mathai-0.5.2 → mathai-0.5.4}/mathai/diff.py +0 -0
  16. {mathai-0.5.2 → mathai-0.5.4}/mathai/expand.py +0 -0
  17. {mathai-0.5.2 → mathai-0.5.4}/mathai/factor.py +0 -0
  18. {mathai-0.5.2 → mathai-0.5.4}/mathai/fraction.py +0 -0
  19. {mathai-0.5.2 → mathai-0.5.4}/mathai/inverse.py +0 -0
  20. {mathai-0.5.2 → mathai-0.5.4}/mathai/linear.py +0 -0
  21. {mathai-0.5.2 → mathai-0.5.4}/mathai/logic.py +0 -0
  22. {mathai-0.5.2 → mathai-0.5.4}/mathai/matrix.py +0 -0
  23. {mathai-0.5.2 → mathai-0.5.4}/mathai/ode.py +0 -0
  24. {mathai-0.5.2 → mathai-0.5.4}/mathai/printeq.py +0 -0
  25. {mathai-0.5.2 → mathai-0.5.4}/mathai/structure.py +0 -0
  26. {mathai-0.5.2 → mathai-0.5.4}/mathai/tool.py +0 -0
  27. {mathai-0.5.2 → mathai-0.5.4}/mathai/trig.py +0 -0
  28. {mathai-0.5.2 → mathai-0.5.4}/mathai/univariate_inequality.py +0 -0
  29. {mathai-0.5.2 → mathai-0.5.4}/mathai.egg-info/SOURCES.txt +0 -0
  30. {mathai-0.5.2 → mathai-0.5.4}/mathai.egg-info/dependency_links.txt +0 -0
  31. {mathai-0.5.2 → mathai-0.5.4}/mathai.egg-info/requires.txt +0 -0
  32. {mathai-0.5.2 → mathai-0.5.4}/mathai.egg-info/top_level.txt +0 -0
  33. {mathai-0.5.2 → mathai-0.5.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Author: educated indians are having a low iq and are good for nothing
@@ -39,7 +39,7 @@ from .logic import logic0, logic1, logic2, logic3
39
39
 
40
40
  from .apart import apart, apart2
41
41
 
42
- from .limit import limit
42
+ from .limit import limit1, limit2, limit0, limit3
43
43
 
44
44
  from .univariate_inequality import wavycurvy, absolute, domain, handle_sqrt
45
45
  from .bivariate_inequality import inequality_solve
@@ -168,9 +168,11 @@ def factor_generation(eq):
168
168
  if eq.name == "f_mul":
169
169
  for child in eq.children:
170
170
  if child.name == "f_pow":
171
+ '''
171
172
  if child.children[0].name[:2] == "s_":
172
173
  output.append(child)
173
174
  continue
175
+ '''
174
176
  if child.children[1].name[:2] != "d_":
175
177
  output.append(child)
176
178
  continue
@@ -332,7 +334,7 @@ def string_equation_helper(equation_tree):
332
334
  if equation_tree.name == "f_index":
333
335
  return string_equation_helper(equation_tree.children[0])+"["+",".join([string_equation_helper(child) for child in equation_tree.children[1:]])+"]"
334
336
  s = "("
335
- if len(equation_tree.children) == 1 or equation_tree.name[2:] in [chr(ord("A")+i) for i in range(26)]+["subs", "try", "ref", "integrate", "exist", "forall", "sum2", "int", "pdif", "dif", "A", "B", "C", "covariance", "sum"]:
337
+ if len(equation_tree.children) == 1 or equation_tree.name[2:] in [chr(ord("A")+i) for i in range(26)]+["limitpinf", "subs", "try", "ref","limit", "integrate", "exist", "forall", "sum2", "int", "pdif", "dif", "A", "B", "C", "covariance", "sum"]:
336
338
  s = equation_tree.name[2:] + s
337
339
  sign = {"f_not":"~", "f_addw":"+", "f_mulw":"*", "f_intersection":"&", "f_union":"|", "f_sum2":",", "f_exist":",", "f_forall":",", "f_sum":",","f_covariance": ",", "f_B":",", "f_imply":"->", "f_ge":">=", "f_le":"<=", "f_gt":">", "f_lt":"<", "f_cosec":"?" , "f_equiv": "<->", "f_sec":"?", "f_cot": "?", "f_dot": ".", "f_circumcenter":"?", "f_transpose":"?", "f_exp":"?", "f_abs":"?", "f_log":"?", "f_and":"&", "f_or":"|", "f_sub":"-", "f_neg":"?", "f_inv":"?", "f_add": "+", "f_mul": "*", "f_pow": "^", "f_poly": ",", "f_div": "/", "f_sub": "-", "f_dif": ",", "f_sin": "?", "f_cos": "?", "f_tan": "?", "f_eq": "=", "f_sqrt": "?"}
338
340
  arr = []
@@ -79,8 +79,10 @@ def subs_heuristic(eq, var):
79
79
  try_index = []
80
80
  try_lst = []
81
81
  def ref(eq):
82
+ '''
82
83
  if eq.name in ["f_try", "f_ref"]:
83
84
  return eq
85
+ '''
84
86
  if eq.name == "f_integrate":
85
87
  return TreeNode("f_try", [eq.fx("ref"), eq])
86
88
  return TreeNode(eq.name, [ref(child) for child in eq.children])
@@ -98,12 +100,12 @@ def _solve_integrate(eq):
98
100
  if eq.name == "f_ref":
99
101
  return eq
100
102
  if eq.name == "f_subs":
101
- if "f_integrate" not in str_form(eq.children[0]):
103
+ if all(item not in str_form(eq.children[0]) for item in ["f_integrate", "f_subs", "f_try"]):
102
104
  return replace(eq.children[0], eq.children[1], eq.children[2])
103
105
 
104
106
  if eq.name == "f_try":
105
107
  for child in eq.children:
106
- if "f_integrate" not in str_form(child):
108
+ if all(item not in str_form(child) for item in ["f_integrate", "f_subs", "f_try"]):
107
109
  return child
108
110
  return TreeNode(eq.name, [_solve_integrate(child) for child in eq.children])
109
111
  def handle_try(eq):
@@ -131,6 +133,7 @@ def inteq(eq):
131
133
  break
132
134
  if eq2 is None:
133
135
  return eq
136
+ printeq(eq)
134
137
  for child in eq.children:
135
138
  if child.name == "f_ref":
136
139
  output.append(child)
@@ -144,6 +147,8 @@ def inteq(eq):
144
147
  output.append(out)
145
148
  else:
146
149
  output.append(child)
150
+ printeq(TreeNode("f_try", output))
151
+ print()
147
152
  return TreeNode("f_try", output)
148
153
  else:
149
154
  return TreeNode(eq.name, [inteq(child) for child in eq.children])
@@ -330,13 +335,20 @@ def byparts(eq):
330
335
  lst = factor_generation(eq)
331
336
  if len(lst) == 3 and len(list(set(lst))) == 1:
332
337
  lst = [(lst[0]**2).copy_tree(), lst[0].copy_tree()]
338
+ if len(lst) == 3 and len(list(set(lst))) == 2:
339
+ lst2 = list(set(lst))
340
+ a, b = lst2
341
+ a = a**lst.count(a)
342
+ b = b**lst.count(b)
343
+ lst = [a.copy_tree(), b.copy_tree()]
333
344
  if len(lst) == 1:
334
345
  lst += [tree_form("d_1")]
335
346
  if len(lst) == 2:
336
347
  for i in range(2):
337
348
 
338
349
  f, g = [lst[i], lst[1-i]]
339
-
350
+ if contain(f, tree_form("s_e")):
351
+ continue
340
352
  out1 = TreeNode("f_integrate", [g.copy_tree(), wrt])
341
353
 
342
354
 
@@ -0,0 +1,156 @@
1
+ from .structure import structure
2
+ from .base import *
3
+ from .parser import parse
4
+ from .simplify import simplify, solve
5
+ from .expand import expand
6
+ from .diff import diff
7
+ from .trig import trig0
8
+ from .fraction import fraction
9
+ from .printeq import printeq
10
+ tab=0
11
+ def substitute_val(eq, val, var="v_0"):
12
+ eq = replace(eq, tree_form(var), tree_form("d_"+str(val)))
13
+ return eq
14
+
15
+ def subslimit(equation, var):
16
+ equation2 = trig0(replace(equation, var, tree_form("d_0")))
17
+
18
+ try:
19
+ tmp = simplify(equation2)
20
+ return simplify(expand(tmp))
21
+ except:
22
+ return None
23
+
24
+ def check(num, den, var):
25
+ n, d = None, None
26
+
27
+ n, d = (dowhile(replace(e, tree_form(var), tree_form("d_0")), lambda x: trig0(simplify(x))) for e in (num, den))
28
+
29
+ if n is None or d is None:
30
+ return False
31
+ if n == 0 and d == 0: return True
32
+ if d != 0:
33
+ return simplify(n/d)
34
+ return False
35
+ def lhospital(num, den, steps,var):
36
+
37
+ out = check(num, den, var)
38
+
39
+ if isinstance(out, TreeNode):
40
+ return out
41
+ for _ in range(steps):
42
+ num2, den2 = map(lambda e: simplify(diff(e, var)), (num, den))
43
+ out = check(num2, den2, var)
44
+ if out is True:
45
+ num, den = num2, den2
46
+ continue
47
+ if out is False:
48
+ eq2 = simplify(fraction(simplify(num/den)))
49
+ return eq2
50
+ return out
51
+ def lhospital2(eq, var):
52
+ eq= simplify(eq)
53
+ if eq is None:
54
+ return None
55
+ if not contain(eq, tree_form(var)):
56
+ return eq
57
+ num, dem = [simplify(item) for item in num_dem(eq)]
58
+ if num is None or dem is None:
59
+ return eq
60
+
61
+ return lhospital(num, dem, 10,var)
62
+ def limit0(equation):
63
+ if equation.name == "f_ref":
64
+ return equation
65
+ eq2 = equation
66
+ g = ["f_limit", "f_limitpinf", "f_limitninf"]
67
+ if eq2.name in g and contain(eq2.children[0], eq2.children[1]):
68
+ equation = eq2.children[0]
69
+ wrt = eq2.children[1]
70
+ lst = factor_generation(equation)
71
+
72
+ lst_const = [item for item in lst if not contain(item, wrt)]
73
+ if lst_const != []:
74
+
75
+ equation = product([item for item in lst if contain(item, wrt)]).copy_tree()
76
+ const = product(lst_const)
77
+ const = simplify(const)
78
+
79
+ if not contain(const, tree_form("s_i")):
80
+
81
+ return limit0(TreeNode(equation.name,[equation, wrt])) *const
82
+ equation = eq2
83
+ return TreeNode(equation.name, [limit0(child) for child in equation.children])
84
+ def limit2(eq):
85
+ g = ["f_limit", "f_limitpinf", "f_limitninf"]
86
+ if eq.name in g and eq.children[0].name == "f_add":
87
+ eq = summation([TreeNode(eq.name, [child, eq.children[1]]) for child in eq.children[0].children])
88
+ return TreeNode(eq.name, [limit2(child) for child in eq.children])
89
+ def limit1(eq):
90
+ if eq.name == "f_limit":
91
+ a, b = limit(eq.children[0], eq.children[1].name)
92
+ if b:
93
+ return a
94
+ else:
95
+ return TreeNode(eq.name, [a, eq.children[1]])
96
+ return TreeNode(eq.name, [limit1(child) for child in eq.children])
97
+ def fxinf(eq):
98
+ if eq is None:
99
+ return None
100
+ if eq.name == "f_add":
101
+ if tree_form("s_inf") in eq.children and -tree_form("s_inf") in eq.children:
102
+ return None
103
+ if tree_form("s_inf") in eq.children:
104
+ return tree_form("s_inf")
105
+ if -tree_form("s_inf") in eq.children:
106
+ return -tree_form("s_inf")
107
+ if eq.name == "f_mul":
108
+ lst = factor_generation(eq)
109
+ if tree_form("s_inf") in lst:
110
+ eq = TreeNode(eq.name, [dowhile(child, fxinf) for child in eq.children])
111
+ if None in eq.children:
112
+ return None
113
+ lst = factor_generation(eq)
114
+ if tree_form("d_0") in lst:
115
+ return tree_form("d_0")
116
+ lst2 = [item for item in lst if "v_" in str_form(item)]
117
+ sign = True
118
+ if len([item for item in lst if "v_" not in str_form(item) and not contain(item, tree_form("s_inf")) and compute(item)<0]) % 2==1:
119
+ sign = False
120
+ if lst2 == []:
121
+ if sign:
122
+ return tree_form("s_inf")
123
+ else:
124
+ return -tree_form("s_inf")
125
+ if eq.name == "f_pow":
126
+ if "v_" not in str_form(eq.children[0]) and not contain(eq.children[0], tree_form("s_inf")) and compute(eq.children[0])>0:
127
+ if eq.children[1] == -tree_form("s_inf"):
128
+ return tree_form("d_0")
129
+
130
+ eq = TreeNode(eq.name, [fxinf(child) for child in eq.children])
131
+ if None in eq.children:
132
+ return None
133
+ return eq
134
+ def limit3(eq):
135
+
136
+ if eq.name == "f_limitpinf":
137
+ if not contain(eq, eq.children[1]):
138
+ return eq.children[0]
139
+ eq2 = replace(eq.children[0], eq.children[1], tree_form("s_inf"))
140
+ eq2 = dowhile(eq2, fxinf)
141
+ if not contain(eq2, tree_form("s_inf")) and not contain(eq2, eq.children[1]):
142
+ return simplify(eq2)
143
+ return TreeNode(eq.name, [limit3(child) for child in eq.children])
144
+
145
+ def limit(equation, var="v_0"):
146
+
147
+ eq2 = dowhile(replace(equation, tree_form(var), tree_form("d_0")), lambda x: trig0(simplify(x)))
148
+ if eq2 is not None and not contain(equation, tree_form(var)):
149
+ return eq2, True
150
+
151
+ equation = lhospital2(equation, var)
152
+ equation = simplify(expand(simplify(equation)))
153
+ if not contain(equation, tree_form(var)):
154
+ return equation, True
155
+
156
+ return equation, False
@@ -59,7 +59,7 @@ grammar = """
59
59
  | ESCAPED_STRING -> string
60
60
  | CAPITAL_ID -> matrix
61
61
 
62
- FUNC_NAME: "midpoint" | "ref" | "subs" | "try" | "forall" | "imply" | "exist" | "len" | "sum" | "angle" | "line" | "sum2" | "charge" | "electricfield" | "perm" | "point" | "equationrhs" | "transpose" | "equationlhs" | "equation" | "error" | "covariance" | "variance" | "expect" | "mag" | "rad" | "laplace" | "diverge" | "pdif" | "gradient" | "curl" | "point1" | "point2" | "dot" | "point3" | "line1" | "line2" | "line3" | "sin" | "circumcenter" | "eqtri" | "linesegment" | "cos" | "tan" | "log" | "sqrt" | "integrate" | "dif" | "abs" | "cosec" | "sec" | "cot" | "arctan" | "arcsin" | "arccos" | "log10"
62
+ FUNC_NAME: "midpoint" | "ref" | "subs" | "try" | "limit" | "forall" | "limitpinf" | "imply" | "exist" | "len" | "sum" | "angle" | "line" | "sum2" | "charge" | "electricfield" | "perm" | "point" | "equationrhs" | "transpose" | "equationlhs" | "equation" | "error" | "covariance" | "variance" | "expect" | "mag" | "rad" | "laplace" | "diverge" | "pdif" | "gradient" | "curl" | "point1" | "point2" | "dot" | "point3" | "line1" | "line2" | "line3" | "sin" | "circumcenter" | "eqtri" | "linesegment" | "cos" | "tan" | "log" | "sqrt" | "integrate" | "dif" | "abs" | "cosec" | "sec" | "cot" | "arctan" | "arcsin" | "arccos" | "log10"
63
63
 
64
64
  VARIABLE: /[a-z]/ | "nabla" | "pi" | "kc" | "hbar" | "em" | "ec" | "anot" | "false" | "true"
65
65
 
@@ -130,7 +130,7 @@ def parse(equation, funclist=None):
130
130
  if tree_node.name == "pass_through":
131
131
  return fxchange(tree_node.children[0])
132
132
  return TreeNode(
133
- "f_" + tree_node.name if tree_node.name in tmp3 + ["try", "ref", "sqrt","imply","forall","exist","exclude","union","intersection","len","index","angle","charge","sum2","electricfield","line","point","sum","transpose","equationrhs","equationlhs","equation","covariance","variance","expect","error","laplace","dot","curl","pdif","diverge","gradient","rad","ge","le","gt","lt","eqtri","linesegment","midpoint","mag","point1","point2","point3","line1","line2","line3","log10","arcsin","arccos","arctan","list","cosec","sec","cot","equiv","or","not","and","circumcenter","eq","sub","add","sin","cos","tan","mul","integrate","dif","pow","div","log","abs"] else "d_" + tree_node.name,
133
+ "f_" + tree_node.name if tree_node.name in tmp3 + ["limitpinf", "limit", "try", "ref", "sqrt","imply","forall","exist","exclude","union","intersection","len","index","angle","charge","sum2","electricfield","line","point","sum","transpose","equationrhs","equationlhs","equation","covariance","variance","expect","error","laplace","dot","curl","pdif","diverge","gradient","rad","ge","le","gt","lt","eqtri","linesegment","midpoint","mag","point1","point2","point3","line1","line2","line3","log10","arcsin","arccos","arctan","list","cosec","sec","cot","equiv","or","not","and","circumcenter","eq","sub","add","sin","cos","tan","mul","integrate","dif","pow","div","log","abs"] else "d_" + tree_node.name,
134
134
  [fxchange(child) for child in tree_node.children]
135
135
  )
136
136
 
@@ -173,6 +173,7 @@ def clear_div(eq, denom=False):
173
173
  return solve(product(lst2)),sign
174
174
 
175
175
  def simplify(eq):
176
+
176
177
  if "v_" not in str_form(eq):
177
178
  n = frac(eq)
178
179
  if n is not None:
@@ -182,6 +183,9 @@ def simplify(eq):
182
183
  return tree_form("d_"+str(n.numerator))/tree_form("d_"+str(n.denominator))
183
184
  else:
184
185
  return tree_form("d_"+str(n.numerator))
186
+
187
+ if contain(eq, tree_form("s_inf")):
188
+ return eq
185
189
  error = False
186
190
  eq = flatten_tree(eq)
187
191
  if eq.name in ["f_and", "f_or", "f_not"]:
@@ -301,6 +305,7 @@ def simplify(eq):
301
305
  error = True
302
306
  else:
303
307
  eq = tree_form("d_0")
308
+
304
309
  if eq.name =="f_pow" and eq.children[0] == tree_form("s_i") and frac(eq.children[1])is not None and frac(eq.children[1]).denominator == 1:
305
310
  n = frac(eq.children[1]).numerator
306
311
  eq = {0:tree_form("d_1"), 1:tree_form("s_i"), 2:tree_form("d_-1"), 3:-tree_form("s_i")}[n%4]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mathai
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: Mathematics solving Ai tailored to NCERT
5
5
  Home-page: https://github.com/infinity390/mathai4
6
6
  Author: educated indians are having a low iq and are good for nothing
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="mathai",
5
- version="0.5.2",
5
+ version="0.5.4",
6
6
  description="Mathematics solving Ai tailored to NCERT",
7
7
  long_description=open("README.md").read(),
8
8
  long_description_content_type="text/markdown",
@@ -1,132 +0,0 @@
1
- from .structure import structure
2
- from .base import *
3
- from .parser import parse
4
- from .simplify import simplify, solve
5
- from .expand import expand
6
- from .diff import diff
7
- from .trig import trig0
8
- from .fraction import fraction
9
- from .printeq import printeq_str
10
- tab=0
11
- def substitute_val(eq, val, var="v_0"):
12
- eq = replace(eq, tree_form(var), tree_form("d_"+str(val)))
13
- return eq
14
-
15
- def subslimit(equation, var):
16
- equation2 = trig0(replace(equation, var, tree_form("d_0")))
17
-
18
- try:
19
- tmp = simplify(equation2)
20
- return simplify(expand(tmp))
21
- except:
22
- return None
23
-
24
- def check(num, den, var):
25
- n, d = None, None
26
-
27
- n, d = (dowhile(replace(e, tree_form(var), tree_form("d_0")), lambda x: trig0(simplify(x))) for e in (num, den))
28
-
29
- if n is None or d is None:
30
- return False
31
- if n == 0 and d == 0: return True
32
- if d != 0:
33
- return simplify(n/d)
34
- return False
35
- def lhospital(num, den, steps,var):
36
- logs = []
37
-
38
- out = check(num, den, var)
39
-
40
- if isinstance(out, TreeNode):
41
- return out,[]
42
- for _ in range(steps):
43
- num2, den2 = map(lambda e: simplify(diff(e, var)), (num, den))
44
- out = check(num2, den2, var)
45
- if out is True:
46
- num, den = num2, den2
47
- logs += [(0,"lim x->0 "+printeq_str(simplify(num/den)))]
48
- continue
49
- if out is False:
50
- eq2 = simplify(fraction(simplify(num/den)))
51
- return eq2,logs
52
- return out,logs
53
- def lhospital2(eq, var):
54
- eq= simplify(eq)
55
- if eq is None:
56
- return None
57
- if not contain(eq, tree_form(var)):
58
- return eq,[]
59
- num, dem = [simplify(item) for item in num_dem(eq)]
60
- if num is None or dem is None:
61
- return eq,[]
62
-
63
- return lhospital(num, dem, 10,var)
64
- ls = [parse("sin(A)"), parse("A^B-1"),parse("log(1+A)"), parse("cos(A)")]
65
- ls= [simplify(item) for item in ls]
66
-
67
- def approx(eq, var):
68
- n, d= num_dem(eq)
69
- n, d = solve(n), solve(d)
70
- n, d = expand(n), expand(d)
71
- out = []
72
- for equation in [n, d]:
73
- for item in factor_generation(equation):
74
- tmp = structure(item, ls[0])
75
- if tmp is not None and contain(tmp["v_-1"], var):
76
- item2 = substitute_val(tmp["v_-1"], 0, var.name)
77
- if tree_form("d_0") == expand(simplify(item2)):
78
- equation = equation/item
79
- equation = equation*tmp["v_-1"]
80
- break
81
- elif tree_form("d_0") == expand(simplify(tree_form("s_pi") - item2)):
82
- equation = equation/item
83
- equation = equation*(tree_form("s_pi") - tmp["v_-1"])
84
- break
85
- tmp = structure(item, ls[1])
86
- if tmp is not None and contain(tmp["v_-1"], var) and not contain(tmp["v_-2"], var):
87
- item2 = substitute_val(tmp["v_-1"], 0, var.name)
88
- item2 = expand(solve(item2))
89
- if tree_form("d_0") == item2:
90
- equation = equation/item
91
- equation = solve(equation*tmp["v_-1"]*tmp["v_-2"].fx("log"))
92
- break
93
- tmp = structure(item, ls[2])
94
- if tmp is not None and contain(tmp["v_-1"], var):
95
-
96
- item2 = substitute_val(tmp["v_-1"], 0, var.name)
97
- item2 = expand(solve(item2))
98
- if tree_form("d_0") == item2:
99
- equation = equation/item
100
- equation = solve(equation*tmp["v_-1"])
101
- break
102
- tmp = structure(item, ls[3])
103
- if tmp is not None and contain(tmp["v_-1"], var):
104
- item2 = substitute_val(item, 0, var.name)
105
-
106
- if tree_form("d_0") == expand(solve(item2)):
107
-
108
- equation = equation/item
109
- equation = equation*(tree_form("d_1") - tmp["v_-1"]**tree_form("d_2"))
110
- break
111
-
112
- equation = solve(equation)
113
- out.append(equation)
114
- return simplify(out[0]/out[1])
115
- def approx_limit(equation, var):
116
- return dowhile(equation, lambda x: approx(x, var))
117
-
118
- def limit(equation, var="v_0"):
119
- logs = [(0,"lim x->0 "+printeq_str(simplify(equation)))]
120
- eq2 = dowhile(replace(equation, tree_form(var), tree_form("d_0")), lambda x: trig0(simplify(x)))
121
- if eq2 is not None and not contain(equation, tree_form(var)):
122
- return eq2,logs
123
-
124
- equation, tmp = lhospital2(equation, var)
125
- equation = simplify(expand(simplify(equation)))
126
- if not contain(equation, tree_form(var)):
127
- return equation,logs+tmp
128
- '''
129
- if equation.name == "f_add":
130
- return simplify(summation([limit(child, var) for child in equation.children]))
131
- '''
132
- return equation,logs+tmp
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes