# Good way to “ensure” a return value

I want to describe an algorithm, which is not changing a given input but it is producing a new element:

\documentclass[a4paper, 11pt]{scrbook}
\usepackage{algorithm}
\usepackage{algorithmic}
...
\begin{algorithmic}
\REQUIRE $\mathcal{P} \subset F[X_1 \dots X_{k-1 }][X_k]$
\ENSURE % something about the return value
\RETURN $\operatorname{Elim}_{X_k}(\mathcal{P})$
\end{algorithmic}


Ensure is not quite the thing I'm looking for because I want to make a statemanent about the output which does not have its own name.

Another thing is that I want to name the algorithm and lateron call it. I know that the algorithm does not to anthing different than call the function Elim but I want to underline the difference between the existence of a mathematical function and the algorithm (e.g. I don't want to discuss the computional complexity of a mathematical function).

Any ideas?

-
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Nov 27 '11 at 18:04

Note that there is no requirement to use the commands provided by the algorithms package - you can define your own.

In the minimal example below I've defined \OUTPUT which typesets Output: just like Ensure: and Require: (actually as an \item).

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

\newcommand{\algorithmicoutput}{\textbf{Output:}}
\newcommand{\OUTPUT}{\item[\algorithmicoutput]}

\begin{algorithmic}
\REQUIRE $\mathcal{P} \subset F[X_1 \dots X_{k-1 }][X_k]$
\OUTPUT Here is a statement about the output.
\RETURN $\operatorname{Elim}_{X_k}(\mathcal{P})$
\end{algorithmic}
\end{document}


I would suggest using the more advanced algorithmicx package. Or, for a more general view on alternatives to the above, see Print programs with its proper syntax.

-