Skip to content

Commit dc19c82

Browse files
committed
minor improvements
1 parent a545d73 commit dc19c82

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

integration_tests/gruntz_demo3.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,38 +127,29 @@ def leadterm(e: S, x: S) -> list[S]:
127127
"""
128128
Returns the leading term a*x**b as a list [a, b].
129129
"""
130-
term1: S = sin(x)/x
131-
term2: S = S(2)*sin(x)/x
132-
term3: S = sin(S(2)*x)/x
133-
term4: S = sin(x)**S(2)/x
134-
term5: S = sin(x)/x**S(2)
135-
term6: S = sin(x)**S(2)/x**S(2)
136-
term7: S = sin(sin(sin(x)))/sin(x)
137-
term8: S = S(2)*log(x+S(1))/x
138-
term9: S = sin((log(x+S(1))/x)*x)/x
139130

140131
l1: list[S] = [S(1), S(0)]
141132
l2: list[S] = [S(2), S(0)]
142133
l3: list[S] = [S(1), S(1)]
143134
l4: list[S] = [S(1), S(-1)]
144135

145-
if e == term1:
136+
if e == sin(x)/x:
146137
return l1
147-
elif e == term2:
138+
elif e == S(2)*sin(x)/x:
148139
return l2
149-
elif e == term3:
140+
elif e == sin(S(2)*x)/x:
150141
return l2
151-
elif e == term4:
142+
elif e == sin(x)**S(2)/x:
152143
return l3
153-
elif e == term5:
144+
elif e == sin(x)/x**S(2):
154145
return l4
155-
elif e == term6:
146+
elif e == sin(x)**S(2)/x**S(2):
156147
return l1
157-
elif e == term7:
148+
elif e == sin(sin(sin(x)))/sin(x):
158149
return l1
159-
elif e == term8:
150+
elif e == S(2)*log(x+S(1))/x:
160151
return l2
161-
elif e == term9:
152+
elif e == sin((log(x+S(1))/x)*x)/x:
162153
return l1
163154
raise NotImplementedError(f"Can't calculate the leadterm of {e}.")
164155

0 commit comments

Comments
 (0)