# Calc of potential function using line integral

I tried to calculate a potential function using the two major methods (by partial differentiation/integration, and by line integral). The two worked with all of the examples that I tried, but then I found one vector field that fails when I use the line integral method.

These are the photos of my calculations:

And using line integral: https://www.dropbox.com/s/79mvvasdydxdpke/line.jpg?dl=0 (this site don't work with dropbox)

My question is why there is this extra x² when a solve using line integral ? Is there a error in my calculations ? This vector field is defined everywhere (at least it seems)...By the way, the first method give the right answer.

As suggested, I wrote the equations in tex to make my question more clear. I'm trying to calculate the potential function of this vector field using the fundamental theorem for line integral.

This is the vector field:

$$\vec{f} = \begin{bmatrix} y\cos{(x)} + 2xe^y \\ \sin{(x)} + x^2e^y -1 \end{bmatrix}$$
And the theorem :

$$\int_{c} \nabla\vec{f}\cdot d\vec{r} = F(a,b) - F(a_o,b_o)$$

the parametric equation is the simple as it can be:

$$c_1$$ = { y = 0; x = t}

$$c_2$$ = { y = t; x = $$x_o$$ }

The following calculations should be self explanatory

$$\int_{c} \vec{f}\cdot d\vec{r} = \int_{c_1} \vec{f}\cdot d\vec{r} + \int_{c_2} \vec{f}\cdot d\vec{r}$$

For the $$c_1$$ path:

$$\int_{c_1} \vec{f}\cdot d\vec{r} = \int_{0}^{x_o} (y\cos{(x)} + 2xe^y)dx + (\sin{(x)} + x^2e^y -1)dy$$

$$\int_{0}^{x_o} 2t dt = t^2\big|_{0}^{x_o} = x_o^2$$

For the $$c_2$$ path:

$$\int_{c_2} \vec{f}\cdot d\vec{r} = \int_{0}^{y_o} (y\cos{(x)} + 2xe^y)dx + (\sin{(x)} + x^2e^y -1)dy$$

$$= \int_{0}^{y_o} \sin{(x_o) + x_o^2e^t - 1} dt = \big[ t\sin{(x_o)} + x_o^2e^t - t \big]_{0}^{y_o}$$

$$= y_o\sin{(x_o)} + x_o^2e^{y_o} - y_o$$

And finally:

$$\int_{c} \vec{f}\cdot d\vec{r} = x_0^2 + y_o\sin{(x_o)} + x_o^2e^{y_o} - y_o = F(x_o,y_o) - F(0,0)$$

$$F(x,y) = y\sin{(x)} + x^2e^y - y + x^2$$

The final result give one extra x² that shouldn't have. I rewrote this and still was unable to spoil my mistake. WHERE IS IT ? Can someone point it to me ?

• Check the substitution $t = 0$ in the integral over $c_2$. $y^t$ should be $e^t$, and you get $x_o^2 e^0$. Commented Feb 7, 2019 at 17:20
• You know that $e^0 \neq 0$, right? Commented Feb 7, 2019 at 19:28
• @Cristiano. In addition to my first answer, I added the comparison of my own calculus with your calculus. Commented Feb 8, 2019 at 9:37
• @maxim Im aware of that, I just didn't evaluate the lower bound, I was a bit too careless... Thanks for your help! Commented Feb 8, 2019 at 11:54

$$y\cos x+2xe^y+(\sin x+x^2e^y-1)y'=0$$

$$\left(y\sin(x)+x^2e^y \right)'=y\cos(x)+2xe^y+\sin(x)y'+x^2e^yy'$$ $$\left(y\sin(x)+x^2e^y \right)'-y'=0$$ Integrate : $$\left(y\sin(x)+x^2e^y \right)-y=C$$ This is the solution of the ODE expressed on the form of implicit equation.

You found :$$\quad y\sin(x)+x^2e^y-y=\varphi$$

This is correct with $$\varphi=$$constant.

In order to get the explicit solution we have to solve the equation for $$y$$. A closed form cannot be obtained with the elementary functions. A special function is required, the Lambert W function. http://mathworld.wolfram.com/LambertW-Function.html

$$y(x)=\frac{C}{\sin(x)-1}-W(X)\qquad\text{with}\qquad X=\frac{x^2\exp(\frac{C}{\sin(x)-1})}{\sin(x)-1}$$

I suppose that was not the expected form if it is a textbook exercise. The above implicit form of solution is probably sufficient.

ADDITION after the comments (the term that you forgot is written in red) :

$$\int_{c_2} \vec{f}\cdot d\vec{r} = \int_{0}^{y_o} (y\cos{(x)} + 2xe^y)dx + (\sin{(x)} + x^2e^y -1)dy$$

$$= \int_{0}^{y_o} \sin{(x_o) + x_o^2e^t - 1} dt = \big[ t\sin{(x_o)} + x_o^2e^t - t \big]_{0}^{y_o}$$

$$= y_o\sin{(x_o)} + x_o^2e^{y_o} - y_o \color{red}{-x_0^2}$$

And finally:

$$\int_{c} \vec{f}\cdot d\vec{r} = x_0^2 + y_o\sin{(x_o)} + x_o^2e^{y_o} - y_o \color{red}{-x_0^2}= F(x_o,y_o) - F(0,0)$$

$$F(x,y) = y\sin{(x)} + x^2e^y - y$$

• I'm sorry but im afraid you didn't understood the question, im not trying to solve de ode, I just don't understand why when I solve for the POTENCIAL FUNCTION of this vector field i get differents results of methods thar should give equal results... Maybe you misunderstood because of the edit maked by someone who seems to didn't get it right neither Commented Feb 6, 2019 at 23:53
• Im not a native English speaker, perhaps the question is not made correctly, could someone edit to me? to make it more clear. Commented Feb 6, 2019 at 23:54
• For me, both methods give the same result. The problem is that your handwriting isn't clear enough. You should type in latex in your question, not on a joint image. Commented Feb 7, 2019 at 7:50