Proof of the Morse Lemma in dimension 1

This is the Morse lemma in dimension1 :

Let $M$ be a smooth $1$-manifold and $f: M \longrightarrow \Bbb R$ be a smooth function. Suppose $p$ is a non-degenerate critical point of $f$.

Then there exists a local coordinate system $(y^1)$ in a neighborhood $U \subset M$ of $p$ with $y^1(p) = 0$ satisfying the identity $$f(y^1) = f(p) - (y^1)^2$$ if the Morse index of $f$ at $p$ is $1$ and the identity $$f(y^1) = f(p) + (y^1)^2$$ if the Morse index of $f$ at $p$ is $0$. (Thank's to @Henry T. Horton)

But how to prove it ?

What are the steps I need to check ?

they say:We first show that if there is any such expression for f,then $\lambda$ must be the index of f at p. For any coordinate system $(z^1,...,z^n)$, if $f(q) = f(p) - (z^1(q))^2- ... - (Z^{\lambda}(q))^2 + (z^{\lambda+1})^2 + ... + (Z^n(q))^2$,..., they want to prove what please ? – Vrouvrou Apr 3 '13 at 13:13
please who is $q$ in the proof , and in dimension 1 ,i must writ $f(q)=f(p)-z(q)^2$ when $\lambda=1$ and $f(q)=f(p)+z(q)^2$ when $\lambda=0$? – Vrouvrou Apr 4 '13 at 8:28
In one variable, Milnor's proof is essentially this: WLOG $f(0)=0$. For $x>0$, let $u=\sqrt{f(x)}$ and for $x<0$ let $u=-\sqrt{f(x)}$. In a neighborhood of $0$, $du/dx>0$, so locally we can write $x=G(u)$. Then $f\circ G(u)=f(x)=u^2$. (The function $v_1=u_1\sqrt{|H_11|}$ is essentially the one I wrote above.) – bmurph Jan 24 '15 at 18:45