Let [tex]x[/tex] and [tex]y[/tex] be the two numbers. We assume that [tex]x[/tex] is greater than [tex]y[/tex]. Then [tex]x-y =40[/tex] which implies that [tex]y = x-40.[/tex]
Their product P is [tex]P = x(x-40) = x^2-40x[/tex]. To find the minimum, we should find the first derivative and set it to zero:
[tex]\frac{dP}{dx} =2x-40= 0.[/tex]
By the second derivative test, since [tex]\frac{d^2 P}{dx^2} = 2 > 0[/tex]
then [tex]P[/tex] has a minimum at [tex]x[/tex].
Therefore, [tex]x = 20[/tex] and the other number is [tex]x-40=20-40=-20[/tex].
Indeed, their difference is [tex]20-(-20)=40.[/tex]