0

I am trying to make an algorithm in LaTeX. For example, I use this template and I want help for this step

First loop mik=aik/akk;

And second loop aij=aij- mikakj;

And finally finish with this final loop

bi=bi=mikbk;

How to write this in LaTeX code?

\section{The algorithm which solves the method Gaussian elimination}
\For{$k$=1$:$1$n-1$}{
    \For{$i=k+1:1:n$}\;
       {write the first loop here}{
      \For{}
      {write the second loop here}
        instructions1\; finish here
        instructions2\;
      {final loop there}
    }{
        instructions3\;
    }
}
\caption{How to write algorithms}

Sorry for this wrong please help to solve this.

2
  • 1
    Please make your code compilable by adding the documentclass as well as the relevant packages. (See also minimal working example (MWE)). Could you please also try to further clarify your question by adding a sketch of the desired output?
    – leandriis
    Nov 30, 2019 at 15:13
  • Ok i add the output Nov 30, 2019 at 15:18

2 Answers 2

2

The following might serve as a place to start from:

\documentclass{article}
\usepackage[ruled]{algorithm2e}

\begin{document}
\begin{algorithm}[H]
    \caption{Test algorithm}
    \SetAlgoLined
    \For{contition}{
        \For{some text here}{
            some text\\
            \For{other stuff}{
                whatever comes here
            }
         some more text
         }
    }

\end{algorithm}
\end{document}
0
\begin{algorithm}[H]
\caption{Test algorithm}
\SetAlgoLined
\For{$k=1:1:n-1$}{
    \For{$i=k+1:1:n$}{
          $m_{i}{k}=a_{i}{k}/a_{k}{k}$\\
        \For{other stuff}{
            $a_{i}{j}=a_{i}{j}-m_{i}{k}a_{k}{j};$\\
        }
        $b_{i}=b_{i}-m_{i}{k}b_{k};$
    }
}\end{algorithm}

is correct

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .