My question is related to the out put of following code. I want the \ddots
to start from the center of the plus sign and continue diagonally. The way it is right now is bit odd. Any help is much appreciated.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newcommand*{\cofrac}[2]{%
{%
\rlap{$\dfrac{1}{\phantom{#1}}$}%
\genfrac{}{}{0pt}{0}{}{#1+#2}%
}%
}
\[
\sqrt{x} =~ \cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{1}{a_3+\cfrac{1}{a_4+{\ddots}}}}}
\]
\end{document}