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
WIP: Formal Power Series #7618
WIP: Formal Power Series #7618
Conversation
|
return solveRE(x, RE, recurr, n, function) | ||
|
||
|
||
class Stream(Expr): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should subclass Stream from Expr. The Stream is a container (just like Tuple) to represent a collections.abc.Iterator, maybe we should add also getitem interface too. You should also think about the efficiency. Do we want to recompute Stream again for first 10 terms?
Probably it's also not a right way to implement Stream's arithmetics (e.g. subclass from Expr and override add and so on). But keep going on as-is, lets build something working first, e.g. Stream(sin(x))*Stream(cos(x))
...
val = [function.diff(x, i).subs(x, 0)/C.factorial(i) for i in range(0, len(terms)-1)] | ||
init = dict(zip(key, val)) | ||
|
||
sol = rsolve(RE, r(k), init) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you can't use rsolve for all cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rsolve cannot solve some cases specially the hypergeometric type.
Ones that are of the form:- P * r(k+m) = Q * r(k)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Some cases" looks like you don't understand well which cases and what's wrong with rsolve.
No doubts - rsolve has algorithms to find solutions for such equations. Do we have a bug with some rsolve_* method or we indeed have a need to implement some new algorighm for rsolve? In the later case - we should improve the recurr module.
Ok, I'm not going into the stuff to find generators, ODE's and so on. (Except for few minor remarks.)
|
Stream now inherits from Basic and acts as a basic container for generator objects. But it still violates the test_args rule. Its argument is a generator object which is not a Basic instance. Sympy should have something to make generators work with its codebase. |
else: | ||
raise TypeError("Invalid argument type") | ||
|
||
def __add__(self, other): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, such methods shouldn't be here.
else: | ||
raise TypeError("Invalid argument type") | ||
|
||
def shift(self, n): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this interface? can't we just use getitem?
raise NotImplementedError('Cannot find simple differential equation for %s' % function) | ||
|
||
|
||
def DEtoRE(DE, r, k): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can replace last two arguments with r(k) instance (AppliedUndef), like in the rsolve.
Lets make something mergeable from this pr. @avichaldayal, here is some todo:
|
PR is stale. Features proposed already in master. Closing. |
Formal power series implementation using lazy recursion.