Why the work of the weight of the pendulum is $mg\cos \theta \ell$?

Why the work of the weight of a pendulum is $$mg\ell\cos \theta$$? Consider the coordinate system $$(O,e_r,e_\theta )$$. Then $$P=(mg\cos\theta ,mg\sin \theta )$$, and thus $$\delta W_P= P\cdot dr.$$ Since the mouvement is a circle, then $$dr=(-\sin\theta ,\cos\theta )$$ and thus $$\delta W_P=-mg\cos\theta \sin\theta +mg\cos\theta \sin\theta =0.$$ Therefore $$W_P=0$$. What's wrong in my argument? • That's a very complicated way of calculating that work! Simply calculate the change in height of the bob: $l[1 - \cos\theta]$. – Gert Dec 15 '18 at 17:19
• @Gert Yes, but it is also a instructive way when you are studying classical mechanics, which is what I assume OP is doing. – Pygmalion Dec 15 '18 at 17:21

Welcome to Physics.SE!

You wrote infinitesimal vector $$d\vec{r}$$ wrongly. It has only component in $$\vec{e}_\theta$$ direction (see your own picture!) that is

$$d\vec{r} = l \: d\theta \: \vec{e}_\theta.$$

Here $$l \: d\theta$$ is the infinitesimal move or arc length for an infinitesimal angle $$d\theta$$.

So infinitesimal work is

$$dW = \vec{P} \cdot d\vec{r} = (mg \cos \theta \: \vec{e}_r + mg \sin \theta \: \vec{e}_\theta) \cdot l \: d\theta \: \vec{e}_\theta = mg \: l \sin \theta \: d\theta.$$

You integrate that for $$\theta$$ from $$\theta$$ to $$0$$ and you get wanted expression

$$W =\int dW = \int_\theta^0 m g l \sin\theta d\theta = m g \: l [1 - \cos\theta].$$

Note that $$l[1 - \cos\theta]$$ is actually height difference.