\(M=a+b+\frac{1}{2a}+\frac{2}{b}\)
\(M=\left(\frac{a}{2}+\frac{1}{2a}\right)+\left(\frac{b}{2}+\frac{2}{b}\right)+\left(\frac{a}{2}+\frac{b}{2}\right)\)
\(M\ge2\sqrt{\frac{a}{2}.\frac{1}{2a}}+2\sqrt{\frac{b}{2}.\frac{2}{b}}+\frac{1}{2}\left(a+b\right)\)
\(M\ge1+2+\frac{3}{2}=\frac{9}{2}\)
\("="\Leftrightarrow a=1;b=2\)