Simple Optimization problem single variable

Very abstractly suppose that the number of tokens I buy depends on the formula

Yinput = sqrt(200000*x) – 10 000

the amount that goes out for the same x somewhere else is

Youtput = 16 853 – ( 500 000/(50.15-sqrt(200000/x) )

In order to have the best profit the difference between Youtput and Yinput must be the biggest possible on a specified interval. (Yout-Yin >>> 0)

Suppose I have an interval of 500 to 550 for x, how do I find the biggest difference between those two functions in those intervals ?

Is there a way to generalize this ?

Also is true that the biggest difference will be at the end of this interval, so when x = 550 ?