$$f(x,p)=2(x+4)(x-2p)$$
Differentiate with respect to x
$$\frac{df(x,p)}{dx}=4x-4p+8$$
Set this equal to zero to find the value of x in terms of p at the minimum
$$4x-4p+8=0 \Rightarrow x=p-2$$
Put this value of x back into the f(x,p), set the result equal to -18 and solve for p
$$2(p-2+4)(p-2-2p)=-18$$
$$(p+2)^2=9$$
$$p+2=\pm3$$
so p = 1 and p = -5
.
$$f(x,p)=2(x+4)(x-2p)$$
Differentiate with respect to x
$$\frac{df(x,p)}{dx}=4x-4p+8$$
Set this equal to zero to find the value of x in terms of p at the minimum
$$4x-4p+8=0 \Rightarrow x=p-2$$
Put this value of x back into the f(x,p), set the result equal to -18 and solve for p
$$2(p-2+4)(p-2-2p)=-18$$
$$(p+2)^2=9$$
$$p+2=\pm3$$
so p = 1 and p = -5
.