# Optimization involving the length of $x$ as the perimeter of two geometric objects

I am having problems understanding how to solve the following optimization problem:

A piece of wire 12 m long is cut into two pieces, the length of the first piece being x m. The first piece is bent into a circle, and the other is bent into a rectangle with length twice the width. Give an expression for the total area A enclosed in the two shapes in terms of x.

In my attempt to solve this was my order of operation:

1. Set up the equation

Perimeter of the circle
$2{\pi}r =x$

Solving for r
$r= \frac{x}{2{\pi}}$

Perimeter of the rectangle

Solving for w
$w = {\frac{12-x}{6}}$

2. Apply both the width and radius to the respective formula's for obtaining the area. Therefore reaching the conclusion

$$A(x) = {\pi}\left(\frac{x}{2{\pi}}\right)^2 + 2\left({\frac{12-x}{6}}\right)^2$$

$$l=2w=2\left({\frac{12-x}{6}}\right)$$ \begin{align} A(x) &= A_{circle}(x)+A_{rectangle}(x) \\ &= \pi r^2+lw \\ &= {\pi}\left(\frac{x}{2{\pi}}\right)^2 + 2\left({\frac{12-x}{6}}\right)\left({\frac{12-x}{6}}\right) \\ &= {\pi}\left(\frac{x}{2{\pi}}\right)^2 + 2\left({\frac{12-x}{6}}\right)^2 \end{align}