Four, (25 points) As shown in the figure,
$3, AB$ is the diameter of $\odot O$, $AB=d$, a tangent line to $\odot O$ is drawn through point $A$ and a point $C$ is taken on it such that $AC = AB$, connect $OC$ to intersect $\odot O$ at point $D$, the extension of $BD$ intersects $AC$ at $E$. Find the length of $AE$.

保留源文本的换行和格式，直接输出翻译结果。
$$
\begin{array}{l}
\angle 1=\angle 2 \\
=\angle 3=\angle 4 .
\end{array}
$$

Therefore, $\triangle C D E \backsim$
$\triangle C A D$, so
$$
\frac{C D}{D E}=\frac{C A}{A D} .
$$

Also, since $\triangle A D E \backsim \triangle B D A$, we have
$$
\frac{A E}{D E}=\frac{A B}{D A} \text {. }
$$

From equations (1), (2), and $A B=A C$, we get $A E=C D$.
Furthermore, since $\angle 1=\angle 4$, $C D$ is the tangent to the circumcircle of $\triangle A D E$. Thus, $C D^{2}=C E \cdot C A$, which means $A E^{2}=C E \cdot C A$.
Let $A E=x$, then $C E=d-x$.
Therefore, $x^{2}=d(d-x)$, which simplifies to $x^{2}+d x-d^{2}=0$.
Solving the equation and taking the positive root, we get $A E=x=\frac{\sqrt{5}-1}{2} d$.