In [2]: rubi_integrate(x**2 + x + 1, x)
Out[2]:
3
x ⌠
── + x + ⎮ x dx
3 ⌡
In [3]: rubi_integrate(x/(x**2+2*x+1), x)
Out[3]:
1
log(x + 1) + ─────
x + 1
In [4]: rubi_integrate(x**2 * exp(x) * cos(x), x)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/Documents/githubRepos/sympy/sympy/sympy/polys/polyutils.py in _parallel_dict_from_expr_if_gens(exprs, opt)
206
--> 207 monom[indices[base]] = exp
208 except KeyError:
KeyError: (x**2)**(1/x)
During handling of the above exception, another exception occurred:
PolynomialError Traceback (most recent call last)
<ipython-input-4-94f6bd418c53> in <module>
----> 1 rubi_integrate(x**2 * exp(x) * cos(x), x)
~/Documents/githubRepos/sympy/sympy/sympy/integrals/rubi/rubi.py in rubi_integrate(expr, var, showsteps)
320 return process_final_integral(results)
321
--> 322 results = rubi.replace(Integral(expr, var), max_count = 10)
323 return process_final_integral(results)
324
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in replace(self, expression, max_count)
794 for subexpr, pos in preorder_iter_with_position(expression):
795 try:
--> 796 replacement, subst = next(iter(self.matcher.match(subexpr)))
797 result = replacement(**subst)
798 expression = functions.replace(expression, pos, result)
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in __iter__(self)
97
98 def __iter__(self):
---> 99 for _ in self._match(self.matcher.root):
100 yield from self._internal_iter()
101
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _match(self, state)
146 for head in heads:
147 for transition in state.transitions.get(head, []):
--> 148 yield from self._match_transition(transition)
149
150 def _match_transition(self, transition: _Transition) -> Iterator[_State]:
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _match_transition(self, transition)
160 yield from self._match_commutative_operation(transition.target)
161 else:
--> 162 yield from self._match_regular_operation(transition)
163 return
164 if isinstance(label, Wildcard) and not isinstance(label, SymbolWildcard):
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _match_regular_operation(self, transition)
308 new_associative = transition.label if issubclass(transition.label, AssociativeOperation) else None
309 self.associative.append(new_associative)
--> 310 for new_state in self._check_transition(transition, subject, False):
311 self.subjects = after_subjects
312 self.associative.pop()
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _check_transition(self, transition, subject, restore_subject)
207 return
208
--> 209 yield from self._match(transition.target)
210
211 finally:
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _match(self, state)
146 for head in heads:
147 for transition in state.transitions.get(head, []):
--> 148 yield from self._match_transition(transition)
149
150 def _match_transition(self, transition: _Transition) -> Iterator[_State]:
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _match_transition(self, transition)
158 if is_operation(label):
159 if transition.target.matcher:
--> 160 yield from self._match_commutative_operation(transition.target)
161 else:
162 yield from self._match_regular_operation(transition)
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _match_commutative_operation(self, state)
290 self.patterns &= potential_patterns
291 for variable in diff:
--> 292 self._check_constraints(variable, restore_constraints, restore_patterns)
293 if not self.patterns:
294 break
~/anaconda3/lib/python3.7/site-packages/matchpy/matching/many_to_one.py in _check_constraints(self, variable, restore_constraints, restore_patterns)
233 self.constraints.remove(constraint_index)
234 restore_constraints.add(constraint_index)
--> 235 if not constraint(self.substitution):
236 restore_patterns |= self.patterns & patterns
237 self.patterns -= patterns
~/anaconda3/lib/python3.7/site-packages/matchpy/expressions/constraints.py in __call__(self, match)
188 args = dict((name, match[var_name]) for name, var_name in self._variables.items())
189
--> 190 return self.constraint(**args)
191
192 def _get_name(self):
~/Documents/githubRepos/sympy/sympy/sympy/integrals/rubi/constraints.py in cons_f590(v, p, u, m, x)
3209 if isinstance(x, (int, Integer, float, Float)):
3210 return False
-> 3211 return PseudoBinomialPairQ(u*x**(m/p), v, x)
3212
3213 cons590 = CustomConstraint(cons_f590)
~/Documents/githubRepos/sympy/sympy/sympy/integrals/rubi/utility_function.py in PseudoBinomialPairQ(u, v, x)
2764
2765 def PseudoBinomialPairQ(u, v, x):
-> 2766 lst1 = PseudoBinomialParts(u, x)
2767 if AtomQ(lst1):
2768 return False
~/Documents/githubRepos/sympy/sympy/sympy/integrals/rubi/utility_function.py in PseudoBinomialParts(u, x)
2746
2747 def PseudoBinomialParts(u, x):
-> 2748 if PolynomialQ(u, x) and Greater(Expon(u, x), S(2)):
2749 n = Expon(u, x)
2750 d = Rt(Coefficient(u, x, n), n)
~/Documents/githubRepos/sympy/sympy/sympy/integrals/rubi/utility_function.py in PolynomialQ(u, x)
1057 if isinstance(x, Pow):
1058 if isinstance(x.exp, Integer):
-> 1059 deg = degree(u, x.base)
1060 if u.is_polynomial(x):
1061 if deg % x.exp !=0 :
~/Documents/githubRepos/sympy/sympy/sympy/polys/polytools.py in degree(f, gen)
4452 p, _ = poly_from_expr(f)
4453 else:
-> 4454 p, _ = poly_from_expr(f, gen)
4455
4456 if isNum:
~/Documents/githubRepos/sympy/sympy/sympy/polys/polytools.py in poly_from_expr(expr, *gens, **args)
4260 """Construct a polynomial from an expression. """
4261 opt = options.build_options(gens, args)
-> 4262 return _poly_from_expr(expr, opt)
4263
4264
~/Documents/githubRepos/sympy/sympy/sympy/polys/polytools.py in _poly_from_expr(expr, opt)
4282 expr = expr.expand()
4283
-> 4284 rep, opt = _dict_from_expr(expr, opt)
4285 if not opt.gens:
4286 raise PolificationFailed(opt, orig, expr)
~/Documents/githubRepos/sympy/sympy/sympy/polys/polyutils.py in _dict_from_expr(expr, opt)
362
363 if opt.gens:
--> 364 rep, gens = _dict_from_expr_if_gens(expr, opt)
365 else:
366 rep, gens = _dict_from_expr_no_gens(expr, opt)
~/Documents/githubRepos/sympy/sympy/sympy/polys/polyutils.py in _dict_from_expr_if_gens(expr, opt)
301 def _dict_from_expr_if_gens(expr, opt):
302 """Transform an expression into a multinomial form given generators. """
--> 303 (poly,), gens = _parallel_dict_from_expr_if_gens((expr,), opt)
304 return poly, gens
305
~/Documents/githubRepos/sympy/sympy/sympy/polys/polyutils.py in _parallel_dict_from_expr_if_gens(exprs, opt)
211 else:
212 raise PolynomialError("%s contains an element of "
--> 213 "the set of generators." % factor)
214
215 monom = tuple(monom)
PolynomialError: (x**2)**(1/x) contains an element of the set of generators.
In [5]: rubi_integrate(exp(-x**2)*erf(x), x)
Out[5]:
⌠
⎮ 2
⎮ -x
⎮ ℯ ⋅erf(x) dx
⌡
Created
March 26, 2019 07:44
-
-
Save Shekharrajak/b37623fa43b6a07cb5d01f99a235f846 to your computer and use it in GitHub Desktop.
sympy.integrals.rubi test
Author
Shekharrajak
commented
Mar 26, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment