# FML

The *Functional Modeling Language* (FML) built inside PetroVR is a algebraic type of language that allows you to easily represent relationships between variables. Its repertoire of predefined functions includes mathematical operations, logic and conditional connectors, financial calculations, etc. - equivalent to the functions and operators used in a MS Excel spreadsheet.

FML is used whenever an input variable is defined as a function (see Input Modes). Variables that can be defined as functions are those found in PetroVR Plan, PetroVR Econ (calculations), PetroVR Portfolio, Depreciation, Globals, and Contracts. Reference can be made both to other input variables and to Runtime Variables; in PetroVR Econ it is also possible to refer to results from Plan.

The main advantage provided by the FML system lies in its flexibility: in combination with User-Defined Variables, it offers the possibility to extend the model to cover any reality of the domain not initially included in the pre-defined model objects.

# On Recursive Expressions in FML

FML expressions become *recursive* when a cycle of references is established between variables and one or more of them is ultimately defined with reference to its own value. In other words, a variable A can be defined as a function of B, B is defined as a function of C, and C in turn contains A - a potential circularity is thus created.

However, when the variables involved are arrays - i.e., whose value evolves so that a different value is recorded for each simulation period - recursive expressions are not necessarily unsolvable, as long as the values referred are those of periods *previous* to the current one (with functions such as previousValue - see Array Functions). A typical example are fiscal regimes, since they are designed to make taxes from one year depend on economic results of previous years. When calculating economic models, PetroVR solves such recursions seamlessly.

Instead, when an FML expression contains unsolvable recursions, the PetroVR validation system detects it immediately and issues an error message, requesting you to correct the expression before running a simulation (see Validation Messages).