Algorithm sections can also be called algorithm equations, since an algorithm section externally is treated as a group of equations involving one or more variables, and can appear among equation sections. An algorithm section is terminated by the appearance of one of the five keywords equation, public, protected, algorithm or end. An algorithm section embedded among equation sections can appear as below, where the example algorithm section contains three assignment statements.
Note that the code in the algorithm section uses the value of certain variables from outside the algorithm section. The variables are also called inputs to the algorithm section (in this example x, y, and z). Analogously, variables assigned values by the algorithm define the outputs of the algorithm (in this example x1 and x2). This makes the semantics of an algorithm section quite similar to a function with the algorithm section as its body, and with input and output formal parameters corresponding to inputs and outputs as described above.