You can insert a formula field into a document (see Inserting a field).
Once you have selected Formula, click on Next to go to the next page.
Click on the Functions button to the right of the Formula box to access all the Ability functions (see Using built-in functions). Alternatively type in a formula directly. You can also type in link expressions for one-way or two-way links. Leaving the Formula box blank will still create a field in your document, although it will be empty. You will still be able to enter text, formulas, etc. directly from the document.
Click on the Show Formula check box if you want the formula, rather than its result, to be displayed in the field.
On the next page you can set a Control Type for the formula field (see Control types).