Basically you want to subtract the 2 curves:
AB = y1 - y2
= [(x-3)^2+7]-[x(4-x)]
= 2x^2 -10x +16
(Length now varies as a function of x)
Next you want to differentiate
Let h = AB = 2x^2 -10x +16
dh/dx = 4x - 10
Stationary points, i.e. gradient is 0
dh/dx = 0
4x - 10 = 0
x = 2.5
Find nature of stationary point - take 2nd derivative
d^2h/dx^2 = 4 < 0, therefore the curve is concave up, and the curve has a minimum value. [Note, if this was 4x you would need to sub in x=2.5]
Minimum length of AB:
AB_min = h(2.5) = 2(2.5)^2 - 10(2.5) + 16 = 3.5 units