There is a field that has an area of $1000$ sq ft. A fence is going to be built around it and it will cost $\$1$ for each foot. Then the field is separated into two pens. One for pigs and one for bulls. For the pens, there will be a wooden wall running parallel to two sides of the field. It will cost $4\$$ for each foot. What length will the wooden wall be if the farmer is paying the least amount for the total cost?
I know one of the equations I will be using is $A=xy$, where $x$ and $y$ are the length and width of the field, respectively.
I am having troubles finding the total cost equation.

Let the cost function to be $C(x,y)=(2x+2y)+4x=6x+2y$, where $x$ and $y$ are the length and width of the field respectively (as defined in your question), and it is assumed that the wooden wall is parallel to the length of the field, i.e. it is $x$ ft long. The unit of $C$ is in dollars.
You can use a Lagrangian multiplier $\lambda$ to set the constraint of your question. The constraint given is that $xy=1000$ sq ft. Rearrange to give $G(x,y)=xy-1000$. The new cost function is $C(x,y)=6x+2y+\lambda(xy-1000)$.
Using the Euler-Lagrange equation in $x$ and $y$ variables, we obtain the following:
Multiplying these two equations to obtain $\lambda$, recalling that $xy=1000$:
$\lambda=\pm\sqrt{\frac{12}{1000}}$
Putting $\lambda$ into the second equation to obtain
$x=-\frac{2}{\lambda}=2\sqrt{\frac{1000}{12}}=\frac{10\sqrt{30}}{3}\approx18.26$ ft.
Note that the negative value of $\lambda$ is taken to obtain a positive $x$ value.