Numerical Analysis Home

## Algorithm

An algorithm is a set of ordered logical operations that applies to a problem defined by a set of data (input data) to produce a solution (output data). An algorithm is usually written in an informal way (pseudocode) before writing it with syntax of a computer language such as C, Java, Python etc. The following is an example of a pseudocode to find $$n!$$:

Algorithm you-name-it
Input: nonnegative integer $$n$$
Output: $$n!$$
$$fact=1$$
for i =2 to n
$$fact=fact*i$$
end for
return $$fact$$

Stopping criteria: Sometimes we need a stopping criteria to terminate an algorithm. For example, when an algorithm approximates a solution $$x^*$$ by constructing a sequence $$\{x_n\}$$, the algorithm needs to stop after finding $$x_k$$ for some $$k$$. There is no universal stopping criteria as it depends on the problem, acceptable error (i.e., error $$<$$ tolerance, say $$10^{-4}$$ ), the maximum number of iterations etc.

Last edited