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

Dsolve shouldn't return series solutions #15916

Open
oscarbenjamin opened this issue Feb 4, 2019 · 4 comments
Open

Dsolve shouldn't return series solutions #15916

oscarbenjamin opened this issue Feb 4, 2019 · 4 comments

Comments

@oscarbenjamin
Copy link
Contributor

For most ODE inputs dsolve returns an exact solution or raises NotImpementedError. Occasionally though it returns a series solution e.g.:

In [32]: dsolve(f(x).diff(x) + sin(x*f(x)**2))                                                                                                 
Out[32]: 
              2  2     3  43    ⎞        
            C₁ x    C₁ x ⎝C₁  + 6⎠    ⎛ 6f(x) = C₁ - ────── + ──────────────── + O⎝x ⎠
              2             24               

Speaking just for myself I never want this solution when calling dsolve. It takes a long time to compute these solutions and there isn't any way of knowing in advance that this will happen.

I think it would be better if obtaining power series solutions was handled by a separate API.

@asmeurer
Copy link
Member

asmeurer commented Feb 4, 2019

Agree, it shouldn't do it unless you use series=True, or even a separate function dsolve_series.

@asmeurer
Copy link
Member

asmeurer commented Feb 4, 2019

there isn't any way of knowing in advance that this will happen.

Technically you can check classify_ode first. But regardless I still think dsolve should only return exact solutions by default.

@divyanshu132
Copy link
Member

I have checked classify_ode and _desolve. I found that whenever classify_ode predicts hint = "1st_power_series" than we will have the series solution.

Let's take a simple example:
dsolve(Eq(y.diff(x), (x+1)/(2-y)))

sympy2

@asmeurer @oscarbenjamin should we modify the hint??

@oscarbenjamin
Copy link
Contributor Author

I think that ideally there would be a separate function for getting series solutions but it's not easy to split it out of dsolve right now.

I guess some people are using this so it needs to go through deprecation.

I suggest to add a new keyword argument series_solutions= to dsolve. This argument should default to None in which case it will do the current behaviour but it should warn if that results in series solutions that obtaining series solutions in that way is deprecated. There should also be a warning if the user provides arguments x0 or n since those should be removed ultimately.

If the user passes False then it should not give series solutions (this should become the default after deprecation).

Otherwise the series_solutions argument can be a dict of values relevant to series solutions (n, x0, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants