(4) Let the ellipse intersect the $x$-axis at points $A$ and $B$. Given that for any point $P$ on the ellipse different from $A$ and $B$, the product of the slopes of lines $AP$ and $BP$ is $-\frac{1}{2}$, then the eccentricity of the ellipse is ( ).
(A) $\frac{1}{\sqrt{3}}$
(B) $\frac{\sqrt{2}}{\sqrt{3}}$
(C) $\frac{1}{2}$
(D) $\frac{1}{\sqrt{2}}$
(4) D Hint: Let $A(1,0)$ and $B(-1,0)$, and suppose $P(x, y)$. Then the slope of line $A P$ is $\frac{y}{x-1}$, and the slope of line $B P$ is $\frac{y}{x+1}$. According to the problem, we have
$$
\frac{y}{x-1} \cdot \frac{y}{x+1}=-\frac{1}{2} .
$$

From this, we get the ellipse equation $x^{2}+2 y^{2}=1$. The eccentricity is $\frac{1}{\sqrt{2}}$.