Skip to content

Built-in functions and Function Studio

Use built-in math functions like sqrt, round, log and sin, define your own such as f(x) = x^2, and keep a reusable library in Zlv Function Studio.

Zlv has a library of math functions, and you can add your own, either inside a sheet or in Function Studio, a library that every sheet can use.

Using a function

Write the function name followed by its arguments in parentheses.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Built-in functions

GroupFunctions
Rounding and signabs, round, ceil, floor, trunc
Powers and logssqrt, exp, ln, log (base 10), log2
Trigonometrysin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh
Countingfactorial (or fact), nCr, nPr, gcd, lcm
Listsmin, max, plus sum, avg, median, count in the desktop app
Randomrandom, randint; see Random, dice and coins
Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Trigonometric functions use degrees by default. Change this in Settings > Calculation > Trigonometric angle unit.

In the desktop engine round also accepts a number of decimal places, and log2 and atan2 are available:

Desktop example
Uses the native Rust engine: copy it into Zlv Desktop to see results.

Results appear next to each line in Zlv Desktop. Download it free.

Defining your own functions in a sheet

Write the function name, its parameter in parentheses, =, and the formula. Then call it on any later line.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

The desktop engine supports several parameters and functions that call other functions:

Desktop example
Uses the native Rust engine: copy it into Zlv Desktop to see results.

Results appear next to each line in Zlv Desktop. Download it free.

Functions you define in a sheet belong to that sheet. To use a function everywhere, save it in Function Studio.

Function Studio (desktop)

Open Function Studio with Ctrl+F or the fx button. It lists the built-in starter functions and your saved functions, with a search box that matches names, parameters, tags and formulas.

  1. Click New Function.
  2. Fill in Function name, Parameters (comma-separated) and Expression body. A Description and Category tag are optional.
  3. Use Test Live to try the function with sample values before saving.
  4. Click Save to Library. The function is now available in every sheet.

From each entry you can Insert Call (adds a call such as bmi() at the cursor), Insert Def (adds the full definition to the sheet), edit, duplicate, copy the definition, or delete it. Restore Defaults brings back the starter set.

The starter library includes:

FunctionWhat it does
bmi(kg, cm)Body mass index from weight and height
discount(price, pct)Price after a percentage discount
tip(bill, pct)Tip amount for a bill
roi(gain, cost)Return on investment, in percent
compound(p, r, y)Compound growth: p * (1 + r) ^ y
vat(x)20% value added tax on an amount
g_forceStandard gravity constant, 9.80665
Desktop example
Uses the native Rust engine: copy it into Zlv Desktop to see results.

Results appear next to each line in Zlv Desktop. Download it free.

Quick insert palette

Press Ctrl+Shift+F to open the function palette, type part of a name such as roi or compound, and insert it at the cursor.

Sharing functions

In Function Studio, Import / Export shows your library as JSON. Use Copy JSON to Clipboard to share it, or paste a JSON array of functions and click Import Functions to add someone else's. Saved functions are stored in your Zlv data folder.

All guides