This problem is from MIT's Single Variable Calculus course. a) Show that the shortest collection of roads joining four towns at four corners of a unit square is given by roads that meet at 120◦ angles. Use the variable x as indicated on the picture. This is not the picture included with the problem but works just as well:
For part a), the perimeter is a unit square. For the length, I used$$L = 4\sqrt{\left(\frac{1}{2}\right)^2 + x^2} + (1 - 2x)$$ Finding the derivative of $L$ and setting it equal to zero, I found that $$x = \frac{1}{2\sqrt{3}}$$ so $$L = 1 + \sqrt{3}$$
As for the angle, $$\tan \left(\frac{\theta}{2}\right) = \frac{1}{2x}$$ so $$\theta = 2\arctan(\sqrt{3}) = 120^{\circ}$$
b) Find the shortest collection of roads in the shape indicated for towns at the four corners of a rectangle. Write down the formula for the length of the roads as a function of $a$. Hint: Sometimes the answer is that the roads meet at $120^\circ$ angles, but only for certain values of $a$.
What I'm really struggling with is writing the length $L$ as a function of $a$. Referring to linked photo, $b = 1$ and $a$ is the unknown length of the rectangle.
One attempt was rewriting $L$ as above but replacing $1$ with $a$: $$L = 4\sqrt{\left(\frac{1}{2}\right)^2 + x^2} + (a - 2x)$$ I took the derivative, treating $a$ as a constant and again have $$x = \frac{1}{2\sqrt{3}}$$ Plugging this into the original equation, I have $$L = \frac{3}{\sqrt{3}} + a$$ I'm not sure if this is the right approach. I've tried solving for $x$ in terms of $a$ but I'm getting that $$x = \frac{a}{4}$$ which would only be true if $a =1$.
Thank you for any input!

Your work appears to show that, as a function of $a$, where fixed $b=1$, $$L = a+\sqrt3$$is the shortest collection of roads linking the four towns. Since setting the derivative equal to $0$ gives the same minimum value of $x=\frac{1}{2\sqrt3}$ for all lengths of the rectangle, the four corner roads do not change in length or angle with increasing $a$. Only the middle road that joins the four increases. And since $$tan\frac{\theta}{2} =\frac{.5}{x}=\sqrt3$$ is also fixed, it seems the roads meet at $120$ degree angles for all values of $a$.