Hi all, this is my first post, and I need help figuring out how to set up this optimization problem. Here it is:

Find the most cost efficient place to build a bridge between two towns, A and B. Town A is located at (-15,10) (measured in kilometers from the origin) and town B is located at (17,-6), with a river between them. It costs 200,000 $/km to build a road from town A to the river, $2,000,000/km to build the bridge, and $190,000/km from the river to Town B.

On the Town A side of the river, the river bank follows the path of:
y = 1 + 2 cos(x/4) * sin(x/7)^3,

while the river bank on the B side follows the path of:
y = -2 + cos(x/2) * sin(x).

Whew, that's a long prompt. So I believe I should be looking for a formula of the Total Cost of the three types of roads in terms of one variable. From there, I should be able to take the derivative, find critical numbers and locate the minimum. I used the distance formula to come up with equations for the cost of the roads. Town A going to point P, town B going to point Q:

Cost of road AP = 200,000(sqrt((15+x)^2+(10-y)^2))

Cost of road BQ = 190,000(sqrt((17-x)^2+(-6-y)^2))

I then replaced the y variable in the two above equations with the corresponding "river bank" functions. This is as far as I got. Am I taking the wrong approach? If not, what's my next step? I need help!

Thanks in advance to anyone taking the time to assist me!