Comment #1 on issue 2408 by [email protected]: Error in rsolve
http://code.google.com/p/sympy/issues/detail?id=2408

Sorry, the last 2 lines should read:

The expected answer is f(0)*2**(n-1)*n

f(n) = (2*n/(n-1))*f(n-1) = (2*n/(n-1))*(2*(n-1)/(n-2))*f(n-2)=...=2**n*FallingFactorial(n,n-1)/(n-1)!f(1)=2**(n-1)*n*f(1)

It seems like the rsolve made the same mistake I did on the post before, to keep unrolling the recurrence, even though the new term can not be evaluated.


Even more if one specifies {f(1):1} it generates an error.

In [2]: print rsolve(2*f(-1 + n) + (1 - n)*f(n)/n,f(n),{f(1):1})
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', (2611, 0))

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

/home/skreft/sympy/sympy/<ipython console> in <module>()

/home/skreft/sympy/sympy/sympy/solvers/recurr.pyc in rsolve(f, y, init)
    751                     equations.append(eq)
    752
--> 753             result = solve(equations, *symbols)
    754
    755             if result is None:

/home/skreft/sympy/sympy/sympy/solvers/solvers.pyc in solve(f, *symbols, **flags)
    362             for g in f:
    363
--> 364                 poly = g.as_poly(*symbols)
    365
    366                 if poly is not None:

/home/skreft/sympy/sympy/sympy/core/basic.pyc in as_poly(self, *gens, **args)
    760
    761         try:
--> 762             poly = Poly(self, *gens, **args)
    763
    764             if not poly.is_Poly:

/home/skreft/sympy/sympy/sympy/polys/polytools.pyc in __new__(cls, rep, *gens, **args)
     99                 return cls._from_poly(rep, opt)
    100             else:
--> 101                 return cls._from_expr(rep, opt)
    102
    103     @classmethod

/home/skreft/sympy/sympy/sympy/polys/polytools.pyc in _from_expr(cls, rep, opt)
    207         """Construct a polynomial from an expression. """
    208         rep, opt = _dict_from_expr(rep, opt)
--> 209         return cls._from_dict(rep, opt)
    210
    211     def __getnewargs__(self):

/home/skreft/sympy/sympy/sympy/polys/polytools.pyc in _from_dict(cls, rep, opt)
    152
    153         if domain is None:
--> 154             domain, rep = construct_domain(rep, opt=opt)
    155         else:
    156             for monom, coeff in rep.iteritems():

/home/skreft/sympy/sympy/sympy/polys/constructor.pyc in construct_domain(obj, **args)
    202
    203     coeffs = map(sympify, coeffs)
--> 204     result = _construct_simple(coeffs, opt)
    205
    206     if result is not None:

/home/skreft/sympy/sympy/sympy/polys/constructor.pyc in _construct_simple(coeffs, opt)
     52
     53         for coeff in coeffs:
---> 54             result.append(domain.from_sympy(coeff))
     55
     56     return domain, result

/home/skreft/sympy/sympy/sympy/polys/domains/pythonrationalfield.pyc in from_sympy(self, a)
     32             return PythonRationalType(*RR.as_integer_ratio(a))
     33         else:
---> 34 raise CoercionFailed("expected `Rational` object, got %s" % a)
     35
     36     def from_ZZ_python(K1, a, K0):

CoercionFailed: expected `Rational` object, got oo


--
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