CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • Core Arithmetic
  • Element-wise (Array) Arithmetic
  • Roots, Logs & Exponents
  • Rounding & Sign
  • Other Utilities
  • Discrete Math Functions
  • Notes for CalcTree
  1. Calculations
  2. Parameters
  3. Math formulas
  4. Native Functions

Arithmetic Functions

PreviousNative FunctionsNextTrigonometric Functions

Last updated 1 day ago

CalcTree supports a full range of arithmetic functions using . These functions form the foundation of most calculations, supporting scalars, vectors, units, and element-wise operations.

You can use these with both raw values (e.g. 3) and unit-aware values (e.g. 3 kN, 200 mm).

Core Arithmetic

Function
Description
CalcTree Example

add(a, b)

Addition

add(2, 3) → 5

subtract(a, b)

Subtraction

subtract(10, 4) → 6

multiply(a, b)

Multiplication

multiply(3, 4) → 12

divide(a, b)

Division

divide(10, 2) → 5

mod(a, b)

Modulus (remainder)

mod(7, 3) → 1

pow(a, b)

Power (a^b)

pow(2, 3) → 8

unaryMinus(x)

Negate a value

unaryMinus(5) → -5

unaryPlus(x)

Returns value unchanged

unaryPlus(5) → 5

Element-wise (Array) Arithmetic

Function
Description
CalcTree Example

dotAdd(a, b)

(Not explicit in MathJS, but implied)

add([1,2], [3,4]) → [4,6]

dotSubtract(a,b)

(Same idea as above)

subtract([5,6], [1,2]) → [4,4]

dotMultiply(a,b)

Element-wise multiplication

dotMultiply([2,3], [4,5]) → [8,15]

dotDivide(a,b)

Element-wise division

dotDivide([6,8], [2,4]) → [3,2]

dotPow(a, b)

Element-wise power

dotPow([2, 3], 2) → [4, 9]

Roots, Logs & Exponents

Function
Description
CalcTree Example

sqrt(x)

Square root

sqrt(25) → 5

cbrt(x)

Cube root

cbrt(27) → 3

nthRoot(x, n)

n-th root

nthRoot(16, 4) → 2

nthRoots(x)

All n-th roots (returns array)

nthRoots(4) → [2, -2]

exp(x)

Euler’s number e to the power of x

exp(1) → 2.718...

expm1(x)

e^x - 1

expm1(1) → 1.718...

log(x)

Natural logarithm (base e)

log(10) → 2.302...

log10(x)

Base-10 log

log10(1000) → 3

log2(x)

Base-2 log

log2(8) → 3

log1p(x)

log(x + 1)

log1p(1) → 0.693...

Rounding & Sign

Function
Description
CalcTree Example

round(x [, n])

Round to nearest integer or decimal

round(2.345, 2) → 2.35

ceil(x)

Round up

ceil(2.1) → 3

floor(x)

Round down

floor(2.9) → 2

fix(x)

Round toward zero

fix(-2.7) → -2

sign(x)

Returns 1 if positive, -1 if negative

sign(-8) → -1

Other Utilities

Function
Description
CalcTree Example

abs(x)

Absolute value

abs(-5) → 5

cube(x)

x * x * x

cube(3) → 27

square(x)

x * x

square(4) → 16

hypot(...)

Euclidean length (Pythagorean)

hypot(3, 4) → 5

norm(x [, p])

Vector or matrix norm

norm([3, 4]) → 5

Discrete Math Functions

Function
Description
CalcTree Example

gcd(a, b)

Greatest common divisor

gcd(18, 24) → 6

xgcd(a, b)

Extended GCD — returns coefficients

xgcd(8, 12) → {gcd: 4, x: -1, y: 1}

lcm(a, b)

Least common multiple

lcm(6, 8) → 24

invmod(a, b)

Modular inverse: x such that a·x ≡ 1 (mod b)

invmod(3, 11) → 4

Notes for CalcTree

  • All arithmetic functions support unit-aware values: e.g., sqrt(25 m²) → 5 m

  • dot* functions are useful when applying operations across arrays from tables

  • Use round(..., n) when formatting outputs for display (e.g. 2 decimal places)

  • Avoid ^ for arrays — prefer pow() or dotPow() to be explicit

📘 Looking for more functions? CalcTree’s expression engine is powered by . For a full list of available functions, visit the . Most functions listed there are supported in CalcTree unless otherwise noted.

MathJS syntax
MathJS
MathJS Function Reference