# How do remove equation number in an algorithm

Here is the code. Even I have used the command \nonumber still I can see the equation number

\begin{document}

\begin{algorithm}

\DontPrintSemicolon % Some LaTeX compilers require you to use \dontprintsemicolon instead
\KwIn{$A,B,C$ }

\KwOut{Optimal value for $x_{2}$ and $\lambda$}
Initialisation: \textit{$\lambda(0)=2\pi/3$ and $\epsilon=10^{-6}$}\\
i=0\\
Compute $x_{2}$
$$x_{2}(i)=\frac {A^2B^2}{\sin\lambda(i)\sqrt{A+B-2C+2\sec\lambda(i)}} \nonumber$$\\
Update $\lambda$
$$\lambda(i+1)=\arctan\bigg( -\frac{A}{2Bx_{2}-1} \bigg) \nonumber$$\\
i=i+1\\
repeat till $|\lambda(i+1)-\lambda(i) |<\epsilon$
\caption{algo}
\label{algo:max}
\end{algorithm}

\end{document}


You can also use the starred version equation* (requires amsmath).

Code

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm2e}

\begin{document}

\begin{algorithm}

\DontPrintSemicolon % Some LaTeX compilers require you to use \dontprintsemicolon instead
\KwIn{$A,B,C$ }

\KwOut{Optimal value for $x_{2}$ and $\lambda$}
Initialisation: \textit{$\lambda(0)=2\pi/3$ and $\epsilon=10^{-6}$}\\
i=0\\
Compute $x_{2}$
\begin{equation*}
x_{2}(i)=\frac {A^2B^2}{\sin\lambda(i)\sqrt{A+B-2C+2\sec\lambda(i)}}
\end{equation*}
Update $\lambda$
\begin{equation*}
\lambda(i+1)=\arctan\bigg( -\frac{A}{2Bx_{2}-1} \bigg)
\end{equation*}
i=i+1\\
repeat till $|\lambda(i+1)-\lambda(i) |<\epsilon$
\caption{algo}
\label{algo:max}
\end{algorithm}

\end{document}


Note that you can remove spurious \\ after .

Remark from Harish Kumar

Just to clarify why \nonumber doesn't remove numbers: \nonumber and/or \notag need amsmath to work. If you add \usepackage{amsmath} then your code with equation and \nonumber works, although it is not a good practice (equation* exists for this purpose).

Use a display equation that is unnumbered: 

\documentclass{article}
\usepackage{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}

\begin{algorithm}
\DontPrintSemicolon % Some LaTeX compilers require you to use \dontprintsemicolon instead
\KwIn{$A,B,C$}
\KwOut{Optimal value for $x_{2}$ and $\lambda$}

Initialisation: \textit{$\lambda(0) = 2\pi/3$ and $\epsilon = 10^{-6}$}\;
$i = 0$\;
Compute $x_2$\;
$x_{2}(i)=\frac {A^2B^2}{\sin\lambda(i)\sqrt{A+B-2C+2\sec\lambda(i)}}$
Update $\lambda$\;
$\lambda(i+1)=\arctan\bigg( -\frac{A}{2Bx_{2}-1} \bigg)$
$i = i + 1$\;
repeat untill $|\lambda(i + 1) - \lambda(i)| < \epsilon$\;
\caption{Caption here}
\label{algo:max}
\end{algorithm}

\end{document}