Solution (source code)

= Solution

Let the neutral edges be $-x_p$ and $x_n$ and take the exterior <electric field> to vanish. Integrating $dE_x/dx=\rho/\varepsilon_s=e\alpha x/\varepsilon_s$ between the edges gives $x_n^2=x_p^2$, so $x_n=x_p=w/2$. This is also the condition of equal and opposite integrated depletion charges.

A second integration with $E_x(w/2)=0$ yields
$$
\boxed{E_x(x)=\frac{e\alpha}{2\varepsilon_s}\left(x^2-\frac{w^2}{4}\right),\qquad |x|\leq\frac w2.}
$$
It is negative inside the layer, pointing from n to p, and zero at both edges. Its largest magnitude occurs at the metallurgical junction:
$$
\boxed{x=0,\qquad |E_x|_{\max}=\frac{e\alpha w^2}{8\varepsilon_s}.}
$$
For reference, choosing $V(-w/2)=0$ gives the cubic <electric potential>
$$
V(x)=\frac{e\alpha}{2\varepsilon_s}\left(\frac{w^2x}{4}-\frac{x^3}{3}+\frac{w^3}{12}\right).
$$