Step 1: Use magnification formula for mirrors.
For mirrors, magnification is given by
\[
m = \frac{v}{u}
\]
Given that the image is real and three times magnified,
\[
m = -3
\]
Step 2: Express image distance in terms of object distance.
From \( m = \frac{v}{u} = -3 \), we get
\[
v = -3u
\]
Step 3: Use given distance between object and image.
The separation between object and image is
\[
|v - u| = 40
\]
Substituting \( v = -3u \),
\[
|-3u - u| = 40 \Rightarrow 4|u| = 40 \Rightarrow u = -10 \text{ cm}
\]
Step 4: Apply mirror formula.
Using
\[
\frac{1}{f} = \frac{1}{v} + \frac{1}{u}
\]
\[
\frac{1}{f} = \frac{1}{30} - \frac{1}{10} = -\frac{1}{15}
\]
\[
f = -15 \text{ cm}
\]