Answer
The combined lengths of roads from town $A$ to expressway and town $B$ to expressway, $f$ in terms of $x$, is, $\sqrt{36+{{x}^{2}}}+\sqrt{{{x}^{2}}-24x+153}$.
Work Step by Step
Consider the length of road from town $A$ to expressway as ${{h}_{1}}$ and the length of road from town $B$ to expressway as ${{h}_{2}}$
According to the Pythagoras theorem
In a right-angle triangle,
${{h}^{2}}={{p}^{2}}+{{b}^{2}}$ …… (1)
Substitute $6$ for $p$ , $x$ for $b$ and ${{h}_{1}}$ for $h$ in equation (1)
$\begin{align}
& {{h}_{1}}=\sqrt{{{6}^{2}}+{{x}^{2}}} \\
& =\sqrt{36+{{x}^{2}}}
\end{align}$
The length of road from town $A$ to expressway
${{h}_{1}}=\sqrt{36+{{x}^{2}}}$
Substitute $3$ for $p$ , $12-x$ for $b$ and ${{h}_{2}}$ for $h$ in equation (1)
${{h}_{2}}=\sqrt{{{3}^{2}}+{{\left( 12-x \right)}^{2}}}$
Use formula ${{\left( A-B \right)}^{2}}={{A}^{2}}-2AB+{{B}^{2}}$ in the above equation
$\begin{align}
& {{h}_{2}}=\sqrt{9+144-24x+{{x}^{2}}} \\
& =\sqrt{153-24x+{{x}^{2}}}
\end{align}$
Or
${{h}_{2}}=\sqrt{{{x}^{2}}-24x+153}$
The length of road from town $B$ to expressway
${{h}_{2}}=\sqrt{{{x}^{2}}-24x+153}$
The combined lengths of roads from town $A$ to expressway and town $B$ to expressway
$f={{h}_{1}}+{{h}_{2}}$
Substitute $\sqrt{36+{{x}^{2}}}$ for ${{h}_{1}}$ and $\sqrt{{{x}^{2}}-24x+153}$ for ${{h}_{2}}$ in the above equation
$f=\sqrt{36+{{x}^{2}}}+\sqrt{{{x}^{2}}-24x+153}$
The required combined lengths of roads from town $A$ to expressway and town $B$ to expressway, $f$ in terms of $x$ , where the distance of towns $A$ and $B$ from expressway are $6\text{ and }3\text{ miles}$ respectively and towns are $12\text{ miles}$ apart from each other, is, $\sqrt{36+{{x}^{2}}}+\sqrt{{{x}^{2}}-24x+153}$.