Let c=cos(theta). Assume also that p≠0.
(1+c^2)/(1+c)=18p^2/4p^4=9/2p^2.
Crossmultiply: 2p^2(1+c^2)=9(1+c); 2p^2c^2-9c+2p^2-9=0.
Using the quadratic formula: c=cos(theta)=(9±√(81-8p^2(2p^2-9)))/4p^2, so cos(theta) is the subject of the equation.
[Under the square root we have 81+72p^2-16p^4=81(1+8p^2/9-16p^4/81).
We know that -1≤c≤1 because of the range of cosine. The square root is positive as long as -2.3307<p<2.3307, approximately.
|(9±√(81-8p^2(2p^2-9)))/4p^2|≤1; 9±√(81-8p^2(2p^2-9))≤4p^2.
81-8p^2(2p^2-9)≤(4p^2-9)^2
81-16p^4+72p^2≤16p^4-72p^2+81
32p^4-144p^2≥0, 16p^2(2p^2-9)≥0, so p≥±3√2/2=±2.12132 approx because p≠0.]