# Optimization: Minimizing the cost of pipeline over land

I have the question "A Gas Outlet is one one side of a river 120 m wide. It is exactly 300 meters downstream and across the river from a cottage. A gas line is to be constructed to join the outlet to the cottage. Underwater, the cost is 13 dollars per meter while on land it is 5 dollars per meter. Determine the length of a line that should be laid on land to minimize the cost of the construction of the pipeline".

I am unsure about how to solve this, I have looked at similar questions and could not find a solution to how I would solve this.

You have one variable to choose, $d$, which is how far downstream the pipe goes while passing under the river. From that, you need to go $300-d$ downstream and $180$ crosswise on dry land and $d$ downstream and $120$ crosswise underwater. Compute the total cost, take the derivative with respect to $d$, set to zero, ...