# 1st_exact_Integral wrong result #11290

Closed
opened this Issue Jun 24, 2016 · 11 comments

Projects
None yet
5 participants
Member

### asmeurer commented Jun 24, 2016

 ```In [15]: dsolve(cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x), f(x), simplify=False, hint='1st_exact_Integral') Out[15]: f(x) ⌠ ⎮ ⎛ 2 ⌠ ⎞ ⌠ ⎮ ⎜y - x⋅sin(y) - ⎮ -sin(y) dx⎟ dy + ⎮ cos(f(x)) dx = C₁ ⎮ ⎝ ⌡ ⎠ ⌡ ⌡ In [16]: dsolve(cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x), f(x), simplify=False, hint='1st_exact_Integral').doit() Out[16]: 3 f (x) ⌠ ───── + ⎮ cos(f(x)) dx = C₁ 3 ⌡ In [17]: dsolve(cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x), f(x), simplify=False, hint='1st_exact') Out[17]: 3 f (x) x⋅cos(f(x)) + ───── = C₁ 3``` You can see the 1st_exact_Integral answer contains `Integral(cos(f(x)), x)` as the term that should be `x*cos(x)` (the `1st_exact` result is correct, as can easily be seen by differentiating the left-hand side). From the general solution (given in the docstring of `ode_1st_exact`) ```>>> from sympy import Function, Eq, Integral, symbols, pprint >>> x, y, t, x0, y0, C1= symbols('x,y,t,x0,y0,C1') >>> P, Q, F= map(Function, ['P', 'Q', 'F']) >>> pprint(Eq(Eq(F(x, y), Integral(P(t, y), (t, x0, x)) + ... Integral(Q(x0, t), (t, y0, y))), C1)) x y / / | | F(x, y) = | P(t, y) dt + | Q(x0, t) dt = C1 | | / / x0 y0``` Here `P(x, y)` is `cos(y)`, so the term should be `Integral(cos(y), x)` (with specifically `y` being a dummy variable not depending on `x`). It looks like this is being done correctly for the `Q` integral but not the `P` one). You can also see https://asmeurersympy.wordpress.com/2009/05/16/work-started-exact-differential-equations/ for more information on 1st exact ODEs.

Member

### asmeurer commented Jun 24, 2016 • edited

 Or rather it should be `Subs(Integral(cos(y), x), y, f(x))`. This explains why this is wrong: `Subs` didn't exist when I wrote this code. The substitution must be happening manually for the non-Integral hint.
Contributor

### parsoyaarihant commented Jun 25, 2016 • edited

 I want to work on this issue. How do I start?

Closed

Contributor

### parsoyaarihant commented Jun 26, 2016

 You can see the 1st_exact_Integral answer contains Integral(cos(f(x)), x) as the term that should be x*cos(x) (the 1st_exact result is correct, as can easily be seen by differentiating the left-hand side). Is `x*cos(x)` a typing error? I think it should be `x*cos(f(x))`.
Member

 Yes

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 6, 2016

``` Fix substitution in 1st_exact_Integral ```
`Closes sympy/sympy#11290`
``` 458cbfa ```

### skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 10, 2016

``` Fix substitution in 1st_exact_Integral ```
`Closes sympy/sympy#11290`
``` b2b3e9b ```
Contributor

### Lakshya1605 commented Oct 7, 2016

 Is it still open if yes i would like to work on this.
Member

### asmeurer commented Oct 7, 2016

 There is this PR, #11299, but I haven't seen any work on it. You might contact the author to see if he plans on finishing it, and if not, you can pick up the work.
Contributor

### Lakshya1605 commented Oct 7, 2016

 `Even "dsolve((f(x)^2-(2_x))+((2_x_f(x))+1)_f(x).diff(x), f(x), simplify=False, hint='1st_exact_Integral').doit() " gives wrong result whereas" dsolve((f(x)^2-(2_x))+((2_x_f(x))+1)_f(x).diff(x), f(x), simplify=False, hint='1st_exact')" gives right result .This issue is happening maybe because in "1st_exact" first we are doing the the integration without substituting whereas in "1st_exact_Integral" followed by "doit()" we are first substituting first y with f(x) and then trying to integrate .The doit() function is then not able to integrate it because it assumes f(x) is dependent on x .So if we only able to replace the "y in Q(x,y) with f(x)" and after calling "doit()" function then replace "y in P(x.y) with f(x) " Then i guess it would work fine . @asmeurer Can you please check whether this would be the right approach . (Sorry I used "^" to represnt power as " ** " was not being accepted here.I am new here and not familiar with how to insert a code here).Thank you.
Member

### asmeurer commented Oct 7, 2016

 Put ` on either side of your code to make it format correctly. See https://guides.github.com/features/mastering-markdown/

Merged

Contributor

### asmeurer added a commit that referenced this issue Oct 10, 2016

``` Merge pull request #11705 from Lakshya1605/11290 ```
`dsolve fix for 1st_exact_Integral #11290`
``` ff8411a ```

### srikanth100 commented Mar 17, 2017

 Is this issue still open?
Member

### smichr commented Mar 26, 2017

 Not any more, it should have been closed with #11705 but there was no magic "Fixes #11290" in the PR.