Hi guys!

I attached a digram explaining the equation and I'd really like to know how to get the cheapest rout

This question has been pondering in my mind for a long lime and I've never known how to work it out

what is the cheapest way of laying the pipe?

also what is the distance between B & X to get the cheapest price?

Thanks in advance!

Edit: Please keep the distance B to X rounded to 3 decimals as that is the closest meter