1
$\begingroup$

I am new at this forum and a beginner with Mathematica. Today I was studying multivariable calculus and I came with this problem. For example, in 2D case I have this code:

DSolve[{D[f[x, y], x] == y*E^(x*y), D[f[x, y], y] == x*E^(x*y)}, f[x, y], {x, y}]

where $\vec{F}=(ye^{xy},xe^{xy})$ and if the vector field was not conservative, DSolve would return unevaluated. But, if my vector field consists of 3 variables, how can I modify my previous code?

For instance, with this vectorial field $\vec{F}(x,y,z) = (y^2z + 2xz^2, 2xyz, xy^2 + 2x^2z)$, I tried:

DSolve[{D[f[x, y, z], x] == y^2 x + 2 x z^2, D[f[x, y, z], y] == 2 x y z, D[f[x, y, z], z] == x y^2 + 2 x^2 z}, f[x, y, z], {x, y, z}]

but it doesn't work. Thanks for your help.

$\endgroup$
2
  • 1
    $\begingroup$ How should MMA know that yiour are looking for a vector function? Instead, try: DSolve[{D[fx[x, y, z], x] == y^2 x + 2 x z^2, D[fy[x, y, z], y] == 2 x y z, D[fz[x, y, z], z] == x y^2 + 2 x^2 z}, {fx, fy, fz}, {x, y, z}] $\endgroup$ – Daniel Huber Nov 12 '20 at 7:47
  • $\begingroup$ Possible duplicates: (36897), (100758), (174082), (202997) $\endgroup$ – Michael E2 Nov 12 '20 at 21:40
1
$\begingroup$

There third and the first component are integrable, because

D[y^2 z + 2 x z^2, z] == D[x y^2 + 2 x^2 z, x]
(*  True *)

The mixed second derivatives are equal. You mistyped that.

Same is

D[y^2 z + 2 x z^2, y] == D[2 x y z, x]
(*  True *)

Same is

D[x y^2 + 2 x^2 z, y] == D[2 x y z, z]
(*  True *)

So this is really a vector field as a derivative of a potential.

Then work stepwise:

DSolve[D[f[x, y, z], x] == y^2 z + 2 x z^2, f[x, y, z], {x, y, z}]

(* {{f[x, y, z] -> x y^2 z + x^2 z^2 + C[1][y, z]}} *)

DSolve[D[x y^2 z + x^2 z^2 + g[y, z], y] == 2 x y z, g[y, z], {y, z}]
(* {{g[y, z] -> C[1][z]}}  *)

DSolve[D[x y^2 z + x^2 z^2 + h[z], z] == x y^2 + 2 x^2 z, h[z], {z}] (* {{h[z] -> C[1]}} *)

f[x,y,z]=x y^2 z + x^2 z^2 + C[1]

Now the gradient can be applied for a check.

Same can be done with

DSolve[{D[fu[x, y, z], x] == y^2 z + 2 x z^2, 
  D[fu[x, y, z], y] == 2 x y z, D[fu[x, y, z], z] == x y^2 + 2 x^2 z},
  fu[x, y, z], {x, y, z}]

(* {{fu[x, y, z] -> x y^2 z + x^2 z^2 + C[1]}} *)

$\endgroup$
0
$\begingroup$

In V12.2, DSolve can solve both examples in the OP:

DSolve[{
  D[f[x, y], x] == y*E^(x*y),
  D[f[x, y], y] == x*E^(x*y)},
 f[x, y], {x, y}]

(*  {{f[x, y] -> E^(x y) + C[1]}}  *)

DSolve[{
  D[f[x, y, z], x] == y^2 z + 2 x z^2, (* fixed typo *)
  D[f[x, y, z], y] == 2 x y z, 
  D[f[x, y, z], z] == x y^2 + 2 x^2 z}, 
 f[x, y, z], {x, y, z}]

(*  {{f[x, y, z] -> x y^2 z + x^2 z^2 + C[1]}}  *)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.