3. Given point $D$ on side $A B$ of $\triangle A B C$, $\angle A$ $=40^{\circ}, \angle B=50^{\circ}, \angle B C D=30^{\circ}, B C=a, A C$ $=b$. Then $C D=(\quad$.
(A) $\frac{\sqrt{2}}{2} \sqrt{a b}$
(B) $\frac{1}{2} \sqrt{a^{2}+b^{2}}$
(C) $\frac{1}{3}(a+b)$
(D) $\frac{1}{4}(2 a+b)$
3. B.

Obviously, $\angle A C B=90^{\circ}$.
As shown in Figure 5, let the midpoint of $A B$ be $M$, and connect $C M$.
$$
\begin{array}{c}
\text { Since } M A=M C, \\
\angle A=40^{\circ}, \\
\text { we know } \angle C M D \\
=2 \times 40^{\circ}=80^{\circ} . \\
\text { Also, } \angle C D M \\
=\angle B+\angle B C D=50^{\circ}+30^{\circ}=80^{\circ}, \\
\Rightarrow \angle C M D=\angle C D M \\
\Rightarrow C D=C M=\frac{1}{2} A B=\frac{1}{2} \sqrt{a^{2}+b^{2}} .
\end{array}
$$