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 fails for a system of independent equations #15574

Open
WFKala opened this Issue Nov 30, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@WFKala
Copy link

WFKala commented Nov 30, 2018

Test case in Sympy 1.3:

from sympy import *
x = symbols('x')
f1 = Function("f1")(x)
f2 = Function("f2")(x)
f3 = Function("f3")(x)
sol = dsolve([
Eq(Derivative(f1,x), f1),
Eq(Derivative(f2,x), f2),
]
)
display(sol)
sol = dsolve([
Eq(Derivative(f1,x), f1),
Eq(Derivative(f2,x), f2),
Eq(Derivative(f3,x), f3),
]
)
display(sol)

Result

[Eq(f1(x), C1exp(x)), Eq(f2(x), C2exp(x))]
[Eq(f1(x), C1*exp(x)), False, False]

If there are two independent equations the result is correct.

If there are three independent equations, the results from dsolve is wrong : it should be solvable but it is not in dsolve.

@oscarbenjamin

This comment has been minimized.

Copy link
Contributor

oscarbenjamin commented Nov 30, 2018

Thanks for reporting this.

This is still the case on master. In fact for 4 equations it's even worse:

In [12]: f1, f2, f3, f4 = symbols('f1 f2 f3 f4', cls=Function)                                                                                                

In [13]: eqs = [Eq(f(x).diff(x), f(x)) for f in (f1, f2, f3, f4)]                                                                                             

In [14]: eqs                                                                                                                                                  
Out[14]: 
⎡d                  d                  d                  d                ⎤
⎢──(f₁(x)) = f₁(x), ──(f₂(x)) = f₂(x), ──(f₃(x)) = f₃(x), ──(f₄(x)) = f₄(x)⎥
⎣dx                 dx                 dx                 dx               ⎦

In [15]: dsolve(eqs[:2])                                                                                                                                      
Out[15]: 
⎡            x              x⎤
⎣f₁(x) = C₁⋅ℯ , f₂(x) = C₂⋅ℯ ⎦

In [16]: dsolve(eqs[:3])                                                                                                                                      
Out[16]: 
⎡            x              ⎤
⎣f₁(x) = C₁⋅ℯ , False, False⎦

In [17]: dsolve(eqs[:4])                                                                                                                                      
Out[17]:2  x       3  x                                2  x                                        ⎤
⎢            x         x   C₃⋅x ⋅ℯ    C₄⋅x ⋅ℯ               x         x   C₄⋅x ⋅ℯ               x         x              x⎥
⎢f₁(x) = C₁⋅ℯ  + C₂⋅x⋅ℯ  + ──────── + ────────, f₂(x) = C₂⋅ℯ  + C₃⋅x⋅ℯ  + ────────, f₃(x) = C₃⋅ℯ  + C₄⋅x⋅ℯ , f₄(x) = C₄⋅ℯ ⎥
⎣                             2          6                                   2

The case with 4 equations is fixed by #15449:

In [4]: dsolve(eqs[:4])                                                                                                                                       
Out[4]: 
⎡            x              x              x              x⎤
⎣f₁(x) = C₁⋅ℯ , f₂(x) = C₂⋅ℯ , f₃(x) = C₃⋅ℯ , f₄(x) = C₄⋅ℯ ⎦

The other cases would be fixed by removing the various 2eq and 3eq functions that handle them and leaving it the fixed neq solver provided by #15449.

@oscarbenjamin

This comment has been minimized.

Copy link
Contributor

oscarbenjamin commented Nov 30, 2018

This is related to #15474

@oscarbenjamin

This comment has been minimized.

Copy link
Contributor

oscarbenjamin commented Nov 30, 2018

Also #15407

skirpichev added a commit to skirpichev/diofant that referenced this issue Dec 1, 2018

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