1 Attachment(s)

Optimization; find my error

an offshore oil well located 5km from the shore. That point is 8km from the oil collection facility. It costs a million dollars per km to build piping in the water and 500,000 dollars per km to build piping on the shore. What location should you place the point where the shore and sea connection to minimize the cost of laying the piping?

Cost = c

oops, The quadratic gives me a negative square root. Where did I go wrong?

P.S. I've solved this done by turning AP into x and PB into 8-x. I get the solution that way. I was trying to do it as above and I cannot get it, Both methods should give me the answer, but THIS way won't work for some reason.