4

(3x^2+4xy)dx+(2x^2+2y)dy=0

I solve this equation on paper like that:

solution

The Result must be:

f(x,y)=x^3+2x^y+y^2=c-c_1

I want to find f(x,y) function in Matlab. I tried to find it using dsolve command.

dsolve ('(2*x^2+2*y)*dy=-(3x^2+4xy)', 'x')

But it's give wrong result.

Is there another solution method???

ccook
  • 5,869
  • 6
  • 56
  • 81
RedLEON
  • 281
  • 2
  • 7
  • 19

2 Answers2

1

It's not that MATLAB is wrong, its solving the ODE for y(x) or x(y). Exact differential equations is something we covered in depth at the graduate level (at least for engineers). It's helpful if you explain the math more before posing this as programming question. Without some explanation how f(x,y) is involved would not be clear.

Posed another way (a bit of a conceptual stretch, but I think it shows F is a potential function well) ...

div({F})= \frac{\partial F}{\partial x} + \frac{\partial F}{\partial y} = (3x^2+4xy) +(2x^2+2y)   = 0

MATLAB will not solve this for you directly. But your result is immediately verifiable when asked in this way since F's involvement is clear.

Note, MATLAB will let you verify symbolically by evaluating diff(f,x) and diff(f,y).

Update

You can get the solution by using MATLAB to perform the steps.

syms x y c
P = 3*x*x + 4*x*y
Q = 2*x*x + 2*y
f = int(P,x)+subs(int(Q,y),x,0) + c

Output

f = c + y^2 + x^2*(x + 2*y)

One line solution

f = int('3*x*x+4*x*y','x') + subs(int('2*x*x+2*y','y'),'x',0) + 'c'
ccook
  • 5,869
  • 6
  • 56
  • 81
  • You absolutely right @ccook. I have about 40 differancial equations to solve. They include every type of diff. equations. I can solve on paper. But my teacher give this homework to solve them in MatLab. I searched many web pages. But there is no example about exact diff. equations on web. At least I didn't find anything. – RedLEON Dec 12 '12 at 14:46
  • Out of curiosity, what grade level? I would expect college - but the use of 'teacher' has me wondering. – ccook Dec 12 '12 at 15:21
  • 1
    University, Industrial Engineering Faculty, Differancial Equations Lesson. :) – RedLEON Dec 12 '12 at 15:32
  • How engineering esque to have a MATLAB assignment for a Differential Equations course/lesson :) – ccook Dec 12 '12 at 15:42
  • They're giving course/lesson. But I missed many Lesson. Cause this departman is distance learning % 70. By the way I tried your solution. Its really nice. I understand your solutions. – RedLEON Dec 12 '12 at 21:38
  • And this is my last solution. What do you think: `syms x y C P=3*x^2+4*x*y Q=2*x^2+2*y Py=diff(P,y) Px=diff(Q,x) iP = int(P,x) iPy = diff(iP, y) h= int('2*y',y) f = iP + h - C` – RedLEON Dec 12 '12 at 21:40
  • Looks good to me - better integrating diff(iP,y) than subbing zero :) – ccook Dec 12 '12 at 23:01
0

Anyway you wrote it wrongly.

I did

>> dsolve ('(2*x^2+2*y)*Dy=-(3*x^2+4*x*y)', 'x')

and got

ans =

   (x^4 - x^3 + C2)^(1/2) - x^2
 - (x^4 - x^3 + C2)^(1/2) - x^2

WOLFRAM

Wolfram Alpha confirms Matlab's solution:

http://www.wolframalpha.com/input/?i=%283x%5E2%2B4xy%29%2B%282x%5E2%2B2y%29y%27%3D0

UPDATE

May be this is coincides with what you get since you express the answer in term of F(x,y) while the solution for DE is f(y)

Dims
  • 47,675
  • 117
  • 331
  • 600
  • Thx @Dims I found it like yours. But My Math teacher want to `f(x,y)=x^3+2x^y+y^2 = C` as result. Maybe dsolve can't give this equation result. Or maybe we must write another way or command. – RedLEON Dec 12 '12 at 10:36
  • I want to find f(x,y) form not f(y). – RedLEON Dec 12 '12 at 10:41
  • Ok having `y = (x^4 - x^3 + C2)^(1/2) - x^2` we have `(y + x^2)^2 = x^4 - x^3 + C2` which gives `y^2 + 2*x^2*y + x^4 = x^4 - x^3 + C2` which gives `y^2 + 2*x^2*y = - x^3 + C2` which is similar to yours except one term. – Dims Dec 12 '12 at 13:07
  • I edited this question and added right solution by image. Could you check it please? – RedLEON Dec 12 '12 at 14:43