Status: Accepted
Owner: [email protected]
Labels: Type-Defect Priority-Medium

New issue 1525 by [email protected]: No integration by substitution
http://code.google.com/p/sympy/issues/detail?id=1525

% ./bin/isympy
Python 2.4.4 console for SymPy 0.6.5.beta3

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z = symbols('xyz')
>>> k, m, n = symbols('kmn', integer=True)
>>> f, g, h = map(Function, 'fgh')

Documentation can be found at http://sympy.org/

In [1]: print(integrate(f(x), x))
Integral(f(x), x)

# That's ok
# And now, instead of

In [2]: print(integrate(f(2*x), x))
Integral(f(x), x)/2

# I get a long failure ending with:
# ValueError: Invalid literal: 2*x is not a valid variable

In [2]: print(integrate(f(2*x), x))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (125, 0))

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call
last)

/scratch/fhagedor/src/sympy-0.6.5.beta3/<ipython console>

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/utilities/decorator.pyc in
threaded_decorator(expr, *args, **kwargs)
      54                     return Add(*[ func(f, *args, **kwargs) for f
in expr.args ])
      55                 else:
---> 56                     return func(expr, *args, **kwargs)
      57
      58         threaded_decorator.__doc__  = func.__doc__

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/integrals/integrals.pyc in
integrate(*args, **kwargs)
     401
     402     if isinstance(integral, Integral):
--> 403         return integral.doit()
     404     else:
     405         return integral

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/integrals/integrals.pyc in
doit(self, **hints)
     132
     133         for x,ab in self.limits:
--> 134             antideriv = self._eval_integral(function, x)
     135
     136             if antideriv is None:

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/integrals/integrals.pyc in
_eval_integral(self, f, x)
     313
     314             # fall back to the more general algorithm
--> 315             h = heurisch(g, x, hints=[])
     316
     317             if h is not None:

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/integrals/risch.pyc in
heurisch(f, x, **kwargs)
     211         return expr.subs(mapping)
     212
--> 213     diffs = [ substitute(simplify(g.diff(x))) for g in terms ]
     214
     215     denoms = [ g.as_numer_denom()[1] for g in diffs ]

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/integrals/risch.pyc in
substitute(expr)
     209
     210     def substitute(expr):
--> 211         return expr.subs(mapping)
     212
     213     diffs = [ substitute(simplify(g.diff(x))) for g in terms ]

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/basic.pyc in
subs(self, *args)
     962             sequence = args[0]
     963             if isinstance(sequence, dict):
--> 964                 return self._subs_dict(sequence)
     965             elif isinstance(sequence, (list, tuple)):
     966                 return self._subs_list(sequence)

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/basic.pyc in
_subs_dict(self, sequence)
    1052                 subst.append(pattern)
    1053         subst.reverse()
-> 1054         return self._subs_list(subst)
    1055
    1056     def _seq_subs(self, old, new):

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/basic.pyc in
_subs_list(self, sequence)
    1005         for old, new in sequence:
    1006             if hasattr(result, 'subs'):
-> 1007                 result = result.subs(old, new)
    1008         return result
    1009

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/basic.pyc in
subs(self, *args)
     969         elif len(args) == 2:
     970             old, new = args
--> 971             return self._subs_old_new(old, new)
     972         else:
     973             raise TypeError("subs accepts either 1 or 2
arguments")

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/cache.pyc in
wrapper(*args, **kw_args)
      83         except KeyError:
      84             pass
---> 85         func_cache_it_cache[k] = r = func(*args, **kw_args)
      86         return r
      87

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/basic.pyc in
_subs_old_new(self, old, new)
     978         old = sympify(old)
     979         new = sympify(new)
--> 980         return self._eval_subs(old, new)
     981
     982     def _eval_subs(self, old, new):

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/function.pyc in
_eval_subs(self, old, new)
     617         if self==old:
     618             return new
--> 619         return Derivative(*map(lambda x: x._eval_subs(old, new),
self.args), **{'evaluate': True})
     620
     621     def matches(pattern, expr, repl_dict={}, evaluate=False):

/scratch/fhagedor/src/sympy-0.6.5.beta3/sympy/core/function.pyc in
__new__(cls, expr, *symbols, **assumptions)
     576             s = sympify(s)
     577             if not isinstance(s, Symbol):
--> 578                 raise ValueError('Invalid literal: %s is not a
valid variable' % s)
     579             if not expr.has(s):
     580                 return S.Zero

ValueError: Invalid literal: 2*x is not a valid variable


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to