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.

-
Side note: this post needs a better title. – user2468 Mar 3 '12 at 18:21
@J.D. What do you suggest? – Pedro Tamaroff Mar 3 '12 at 19:28
@PeterT.off The title should tell about the formula, e.g. "Solving 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}$" – user2468 Mar 3 '12 at 20:00
"Solving" is not the right word here. "Finding" or "evaluating" would fit. The usage is never taught but seems nearly universal among non-mathematicians. – Michael Hardy Mar 3 '12 at 20:04
@MichaelHardy I think you have fixed it while approving my edit! – user2468 Mar 3 '12 at 20:06

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}

-