Domanda

(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???

È stato utile?

Soluzione

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'

Altri suggerimenti

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)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top