Consider the vector field defined by: $$\vec F(x,y)=\langle 2xy-\sin x,x^2+e^{3y}\rangle$$ We can check to see if the vector field is conservative with the following calculations: $$\begin{align*} \frac{\partial}{\partial x}(x^2+e^{3y})=2x\\ \frac{\partial}{\partial y}(2xy-\sin x)=2x\\ \end{align*}$$ Now, I am interested in looking at several different procedures for finding a scalar function $f(x,y)$ such that $\vec F(x,y)=\nabla f(x,y)$. Can folks share their ideas?
Update: Sure, students need to attack this by hand in class in the following manner.
$$\begin{align*} \vec F(x,y)&=\nabla f(x,y)\\ \langle 3+2xy, x^2-3y^2\rangle&=\langle\partial f/\partial x, \partial f/\partial y\rangle \end{align*}$$
They start by setting $$\frac{\partial f}{\partial x}=3+2xy,$$ then integrate with respect to $x$. $$f(x,y)=3x+x^2y+h(y)$$ The second step is to set: $$\begin{align*} \frac{\partial f}{\partial y}&=x^2-3y^2\\ \frac{\partial}{\partial y}(3x+x^2y+h(y))&=x^2-3y^2\\ x^2+h'(y)&=x^2-3y^2 \end{align*}$$ The last line gives us $$h'(y)=-3y^2,$$ then integrating gives us $$h(y)=-y^3.$$ Subbing this into $f(x,y)=3x+x^2y+h(y)$ gives the final answer. $$f(x,y)=3x+x^2y-y^3$$
So I am trying:
Clear[f, h, x, y, p, q]
p = 3 + 2 x y;
q = x^2 - 3 y^2;
Then I perform the conservative test:
D[p, y]
D[q, x]
Which gives:
(* 2x *)
(* 2x *)
So we do have a conservative vector field. Next:
f=Integrate[p,x]+h[y]
Which gives:
(* 3 x + x^2 y + h[y] *)
Next, I run:
Solve[D[f, y] == q, h'[y]]
Which gives:
(* {{Derivative[1][h][y] -> -3 y^2}} *)
Then I do this:
Integrate[-3 y^2, y]
Which gives:
(* -y^3 *)
Then I do this:
f = f /. h[y] -> -y^3
Which gives the final answer:
(* 3 x + x^2 y - y^3 *)
I love the answers I have received thus far, but would also like to see what folks do to purify my attempt.