Compute $\int_{\gamma} \nabla f \cdot d\mathbf{x}$ for the following choices of $f$ and $\gamma$.
(a) $f(x,y) = x^2+y^2; \gamma:g(t) = (1+t^2, 1-t^2), -1 \le t \le2$
What I have tried: $$\int_{-1}^2(1+t^2)^2dx + \int_{-1}^2(1-t^2)^2dy$$
Where $dx = 2t$ and $dy = -2t$ So we have $$\int_{-1}^2(1+t^2)^2(2t)dt + \int_{-1}^2(1-t^2)^2(-2t)dt$$
however this outputs the wrong result. How do I proceed from here>?
Note that $f(x, y) = x^2 + y^2$, so the vector field $\nabla f$ is $$ \nabla f (x, y) = (2x, 2y).$$ By definition, \begin{align} \int_\gamma \nabla f \cdot dx &= \int_{-1}^2 2(1+ t^2) 2t dt + \int_{-1}^2 2 (1-t^2) (-2t) dt, \end{align} which gives $30$.
In general, when the vector fields in the gradient of a function, the line integral depends only on the end points but not the path: for any path $\gamma : [a, b]\to \mathbb R^2$,
$$\int_\gamma \nabla f \cdot dx = f(\gamma(b)) - f(\gamma(a)).$$
In our case $$f(\gamma(b)) - f(\gamma(a)) = f(\gamma(2)) - f(\gamma(-1)) =f(5, -3) - f(2,0) = 25 + 9 - 4 = 30.$$