2. Given a square $A B C D$ with side length $1, P$ is a point on $A C$ different from $A$ and $C$, point $E$ is on $C D$, and $P E$ $\perp P B$. If $A P=x$, the area of pentagon $A B P E D$ is $y$, then the relationship between $y$ and $x$ is $\qquad$ .
2. $y=-\frac{1}{2} x^{2}+\sqrt{2} x\left(0<x<\frac{\sqrt{2}}{2}\right)$.

As shown in Figure 4, draw $PG \perp BC$ and $PH \perp CD$, with $G$ and $H$ being the feet of the perpendiculars. Then quadrilateral $PGCH$ is a rectangle.

Since $CP$ is the angle bisector of $\angle BCD$, we have $PG = PH$.

Therefore, quadrilateral $PGCH$ is a square.
Since $\angle BPE = \angle GPH = 90^{\circ}$, we have $\angle BPG = \angle EPH$.
Thus, $\triangle BPG \cong \triangle EPH$.
Hence, $S_{\triangle BPG} = S_{\triangle EPH}$.
At this point, $S_{\text{quadrilateral } BPEC} = S_{\text{square } PGCH}$.
In square $ABCD$, it is easy to see that $AC = \sqrt{2}$, and $PC = \sqrt{2} - x$.
Therefore, $S_{\text{square } PGCH} = \frac{1}{2}(\sqrt{2} - x)^{2}$.
Thus, $y = S_{\text{square } ABCD} - S_{\text{quadrilateral } BPEC} = 1 - \frac{1}{2}(\sqrt{2} - x)^{2} = -\frac{1}{2} x^{2} + \sqrt{2} x\left(0 < x < \frac{\sqrt{2}}{2}\right)$.