Evaluating the line integral $\int(x-y)dS$ for $r^2=a^2\cos(2\phi)$ and $-\frac{\pi}{4} \leq \phi \leq \frac{\pi}{4}$ $$ \int(x-y)dS $$ where $$ r^2=a^2\cos(2\phi) $$ and $$ -\frac{\pi}{4} \leq \phi \leq \frac{\pi}{4}$$
Since $ r=a\sqrt{\cos(2\phi)}$, do I convert $ x=r\cos(\phi) $ and $ y=r\sin(\phi) $ into $$ x=a\sqrt{\cos(2\phi)}\cos(\phi) $$ and $$ y=a\sqrt{\cos(2\phi)}\sin(\phi) $$ and then calculate $$ dS=\sqrt{\left(\frac{dx}{d\phi}\right)^2 + \left(\frac{dy}{d\phi}\right)^2} $$ or do I calculate $dS$ by leaving $ x=r\cos(\phi)$ and $y=r\sin(\phi)$? 
I'm asking because I seem to get slightly different solutions.
 A: I'm also learning line integration, but I think I got this one right.
You want to find
$$\sqrt {{{\left( {\frac{{dx}}{{d\phi }}} \right)}^2} + {{\left( {\frac{{dy}}{{d\phi }}} \right)}^2}} $$
We have that
$$\eqalign{
  & \frac{{dx}}{{d\phi }} = \frac{{dr}}{{d\phi }}\cos \phi  - r\sin \phi   \cr 
  & \frac{{dy}}{{d\phi }} = \frac{{dr}}{{d\phi }}\sin \phi  + r\cos \phi  \cr} $$
So we get
$$\eqalign{
  & {\left( {\frac{{dx}}{{d\phi }}} \right)^2} = {\left( {\frac{{dr}}{{d\phi }}} \right)^2}{\cos ^2}\phi  - 2\frac{{dr}}{{d\phi }}r\cos \phi \sin \phi  + {r^2}{\sin ^2}\phi   \cr 
  & {\left( {\frac{{dy}}{{d\phi }}} \right)^2} = {\left( {\frac{{dr}}{{d\phi }}} \right)^2}{\sin ^2}\phi  + 2\frac{{dr}}{{d\phi }}r\cos \phi \sin \phi  + {r^2}{\sin ^2}\phi  \cr} $$
This means that
$${\left( {\frac{{dx}}{{d\phi }}} \right)^2} + {\left( {\frac{{dy}}{{d\phi }}} \right)^2} = {\left( {\frac{{dr}}{{d\phi }}} \right)^2} + {r^2}$$
(Actually, this is a known result, namely that in polar coordinates one has 
$$ds = \sqrt{r^2+r'^2}d\phi$$
Moving on, we have 
$$\eqalign{
  & {r^2} = {a^2}\cos 2\phi   \cr 
  & {\left( {\frac{{dr}}{{d\phi }}} \right)^2} = {a^2}\frac{{\sin 2\phi }}{{\cos 2\phi }}\sin 2\phi  \cr} $$
So
$$\sqrt {{{\left( {\frac{{dr}}{{d\phi }}} \right)}^2} + {r^2}}  = \sqrt {\frac{{{a^2}\left( {{{\sin }^2}2\phi  + {{\cos }^2}2\phi } \right)}}{{\cos 2\phi }}}  = \frac{a}{{\sqrt {\cos 2\phi } }}$$
The integral ends up being rather "user friendly"
$$\eqalign{
  & {a^2}\int\limits_{ - \pi /4}^{\pi /4} {\frac{{\sqrt {\cos 2\phi } \cos \phi  - \sqrt {\cos 2\phi } \sin \phi }}{{\sqrt {\cos 2\phi } }}} d\phi   \cr 
  & {a^2}\int\limits_{ - \pi /4}^{\pi /4} {\left( {\cos \phi  - \sin \phi } \right)} d\phi  = {a^2}\sqrt 2  \cr} $$
