Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsolve should handle hypergeometric inhomogeneous terms #451

Closed
pedritomelenas opened this issue Mar 1, 2017 · 6 comments
Closed

rsolve should handle hypergeometric inhomogeneous terms #451

pedritomelenas opened this issue Mar 1, 2017 · 6 comments
Labels
bug an unexpected problem or unintended behavior solvers
Milestone

Comments

@pedritomelenas
Copy link

It seems that so far rsolve can only handle rational inhomogeneous part: rsolve( x(n)-2*x(n-1)-3**n, x(n),[1]) yields

ValueError: Inhomogeneous part should be a rational function of 'n', got '3**n'

It could be nice to have also parts of the form a^nf(n) with a a positive integer and f(n) a polynomial, as in sympy where rsolve( x(n)-2*x(n-1)-3**n, x(n),[1]) ouputs

-2*2**n + 3*3**n

Thank you,
Pedro

@skirpichev skirpichev added bug an unexpected problem or unintended behavior solvers labels Mar 1, 2017
@skirpichev
Copy link
Collaborator

I think, that's a (trivial) bug. Current implementation should work for hypergeometric terms too.

Also, instead of raising ValueError - there should be (for non-hypergeometric terms) NotImplementedError instead.

@skirpichev skirpichev added this to the 0.9.0 milestone Mar 1, 2017
skirpichev added a commit to skirpichev/diofant that referenced this issue Mar 1, 2017
@skirpichev skirpichev changed the title Feature request: rsolve to handle more nonhomogeneous terms rsolve should handle hypergeometric inhomogeneous terms Mar 1, 2017
@skirpichev
Copy link
Collaborator

Issue retitled. Let me know if you think it's not accurate now.

@pedritomelenas
Copy link
Author

Better. Thanks

@pedritomelenas
Copy link
Author

Thanks, now rsolve(x(n)-2*x(n-1)-3**n,x(n),[1]) works.
However I cannot make it to work for n*3**n: rsolve(x(n)-2*x(n-1)-3**n*n,x(n),[1]) yields an AttributeError.
Thank you,
Pedro

@skirpichev
Copy link
Collaborator

hypersimp() call on line 547 fails. If you make simplify(g) - it works:

In [1]: rsolve(f(n)-2*f(n-1)-3**n*n, f(n),[1])
Out[1]: 
   n    n + 1        
72  + 3     ⋅(n - 2)

However, I think this should be a separate issue.

@skirpichev
Copy link
Collaborator

#456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior solvers
Projects
None yet
Development

No branches or pull requests

2 participants