Variable naming syntax

CalcTree variables use custom syntax that let you create variables that work as functional calculations (in 'code-friendly' form) while displaying also rendering as clean mathematical notation. This system uses underscores and special keywords to control subscripts, superscripts, mathematical symbols, and other formatting.

Basic Concepts

Simple Names

  • Regular variable names display as-is:

    • velocityvelocityvelocity

    • forceforceforce

    • temperaturetemperaturetemperature

  • Names ending with underscore use regular font with spaces:

    • total_cost_total costtotal \space cost

    • heat_flow_rate_heat flow rateheat \space flow \space rate

    • max_speed_max speedmax \space speed

    • Note: The trailing underscore converts underscores to spaces

Special Separators

Single Underscore _ Rules

A single underscore has different meanings depending on what follows it:

For regular text - creates subscripts:

  • v_maxvmaxv_{max}

  • F_appliedFappliedF_{applied}

  • x_1x1x_1

For Greek keywords - converts and subscripts:

  • alpha_1α1\alpha_1 (converts 'alpha' to α and subscripts '1')

  • sigma_yieldσyield\sigma_{yield}(converts 'sigma' to σ and subscripts 'yield')

For special keywords - triggers special formatting:

  • x_prmxx' (prime right notation)

  • prm_xx'x (prime left notation)

  • ovr_xxˉ (overline for averages)

Combined with double underscore for superscripts:

  • x_1__2 → x12 (x subscript 1, squared)

  • v_final__2 → vfinal2 (final velocity squared)

Formatting Syntax

Subscripts and Superscripts

Use underscores followed by special placeholders:

Syntax
Result
Example

name_text

Subscript

v_maxvmaxv_{max}

name__text

Superscript

x__2x2x^2

name_sub__sup

Both

x_i__2xi2x_i^2

Complete Mathematical Symbol Reference

CalcTree automatically converts certain keywords to mathematical symbols when a variable is rendered on the page:

Lowercase Greek

Keyword
Symbol
Example
Display

alpha

α

alpha_1

α1\alpha_{1}

beta

β

beta_coefficient

βcoefficient\beta_{coefficient}

gamma

γ

gamma_ray

γray\gamma_{ray}

delta

δ

delta_t

δt\delta_{t}

epsilon

ε

epsilon_0

ϵ0\epsilon_{0}

zeta

ζ

zeta_function

ζfunction\zeta_{function}

eta

η

eta_efficiency

ηefficiency\eta_{efficiency}

theta

θ

theta_angle

θangle\theta_{angle}

iota

ι

iota_value

ιvalue\iota_{value}

kappa

κ

kappa_constant

κconstant\kappa_{constant}

lambda

λ

lambda_wavelength

λwavelength\lambda_{wavelength}

mu

μ

mu_friction

μfriction\mu_{friction}

nu

ν

nu_frequency

νfrequency\nu_{frequency}

xi

ξ

xi_parameter

ξparameter\xi_{parameter}

omicron

ο

omicron_value

οvalue\omicron_{value}

pi

π

pi_constant

πconstant\pi_{constant}

rho

ρ

rho_density

ρdensity\rho_{density}

sigma

σ

sigma_stress

σstress\sigma_{stress}

tau

τ

tau_torque

τtorque\tau_{torque}

upsilon

υ

upsilon_velocity

υvelocity\upsilon_{velocity}

phi

φ

phi_angle

ϕangle\phi_{angle}

chi

χ

chi_squared

χsquared\chi_{squared}

psi

ψ

psi_wave

ψwave\psi_{wave}

omega

ω

omega_angular

ωangular\omega_{angular}

Uppercase Greek

Keyword
Symbol
Example
Display

Alpha

Α

Alpha_particle

Aparticle\Alpha_{particle}

Beta

Β

Beta_function

Bfunction\Beta_{function}

Gamma

Γ

Gamma_distribution

Γdistribution\Gamma_{distribution}

Delta

Δ

Delta_H

ΔH\Delta_{H}

Epsilon

Ε

Epsilon_field

Efield\Epsilon_{field}

Zeta

Ζ

Zeta_potential

Zpotential\Zeta_{potential}

Eta

Η

Eta_meson

Hmeson\Eta_{meson}

Theta

Θ

Theta_temperature

Θtemperature\Theta_{temperature}

Iota

Ι

Iota_index

Iindex\Iota_{index}

Kappa

Κ

Kappa_number

Knumber\Kappa_{number}

Lambda

Λ

Lambda_baryon

Λbaryon\Lambda_{baryon}

Mu

Μ

Mu_mass

Mmass\Mu_{mass}

Nu

Ν

Nu_neutrino

Nneutrino\Nu_{neutrino}

Xi

Ξ

Xi_cascade

Ξcascade\Xi_{cascade}

Omicron

Ο

Omicron_variant

Ovariant\Omicron_{variant}

Pi

Π

Pi_product

Πproduct\Pi_{product}

Rho

Ρ

Rho_meson

Pmeson\Rho_{meson}

Sigma

Σ

Sigma_sum

Σsum\Sigma_{sum}

Tau

Τ

Tau_lepton

Tlepton\Tau_{lepton}

Upsilon

Υ

Upsilon_meson

Υmeson\Upsilon_{meson}

Phi

Φ

Phi_flux

Φflux\Phi_{flux}

Chi

Χ

Chi_distribution

Xdistribution\Chi_{distribution}

Psi

Ψ

Psi_function

Ψfunction\Psi_{function}

Omega

Ω

Omega_resistance

Ωresistance\Omega_{resistance}

Greek Variations

Keyword
Symbol
Description

varepsilon

ε\varepsilon

Variant epsilon

varkappa

ϰ\varkappa

Variant kappa

varphi

φ\varphi

Variant phi

varpi

ϖ\varpi

Variant pi

varrho

ϱ\varrho

Variant rho

varsigma

ς\varsigma

Variant sigma

vartheta

ϑ\vartheta

Variant theta

Special Mathematical Symbols

Keyword
Symbol
Example
Display

infty

T_infty

TT_{\infty}

diameter

d_diameter

dd_{\varnothing}

circ

°

angle_circ

angleangle_{\circ}

mid

|

x_mid

xx_{\mid}

degree

°

temp_degree

temp°temp_{\degree}

star

rating_star

ratingrating_{\star}

Punctuation & Operators

These symbols are inserted in the baseline (not as subscripts) when preceded by a single underscore:

Keyword
Symbol
Example
Display

prm

'

x_prm

xx'

dot

.

v_dot

v˙\dot{v}

cma

,

item_cma_1

item,1item, 1

div

/

m_div_s

m/sm/s

spc

(space)

total_spc_cost

total  costtotal \; cost

num

#

item_num_5

item#5item\#5

pls

+

charge_pls

charge+charge+

mns

-

ion_mns

ionion-

Special Directives

These create formatting effects:

Keyword
Effect
Example
Display

sqrt

Square root

value_sqrt

value\sqrt{value}

prn

Parentheses

sum_prn

(sum)(sum)

ovr

Overline

x_ovr

x\overline{x}

Advanced Formatting

Special placeholder keywords after underscores:

Examples

Engineering Variables

Stress components:

  • sigma_xxσxx\sigma_{xx} (sigma with xx subscript)

  • sigma_y__2σy2\sigma_{y}^{2} (sigma with y subscript and squared)

  • tau_xyτxy\tau_{xy} (shear stress)

Heat transfer:

  • q_dot_q  dotq \; dot (heat flux, regular font)

  • T_inftyTT_{\infty} (temperature at infinity)

  • alpha_thermalαthermal\alpha_{thermal} (thermal diffusivity)

Electrical:

  • V_rmsVrmsV_{rms} (RMS voltage)

  • I_peak__2Ipeak2I^{2}_{peak} (peak current squared)

  • Omega_resistanceΩresistance\Omega_{resistance} (resistance in ohms)

Physics & Mathematics

Wave functions:

  • psi_nψn\psi_{n} (wave function n)

  • Psi_totalΨtotal\Psi_{total} (total wave function)

Statistics:

  • mu_populationμpopulation\mu_{population} (population mean)

  • sigma_xσx\sigma_{x} (standard deviation)

  • chi__2χ2\chi^{2} (chi-squared)

Calculus:

  • Delta_xΔx\Delta_{x} (change in x)

  • epsilon_0ϵ0\epsilon_{0} (permittivity of free space)

Reserved Keywords

These words cannot be used as variable names:

MathJS Reserved: mod, to, in, and, xor, or, not, end

Python Reserved (for compatibility): False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield

Best Practices

  1. Use meaningful base names: sigma_yield is better than just sigma

  2. Be consistent: Use the same naming patterns throughout your project

  3. Consider context: Delta_T for temperature change, delta_small for small changes

  4. Mix symbols wisely: alpha_beta_ratioαbeta_ratio\alpha_{beta\_ratio} (only first part converts)

Quick Reference Card

  • Basic subscript: variable_subscriptvariablesubscriptvariable_{subscript}

  • Basic superscript: variable__superscriptvariablesuperscriptvariable^{superscript}

  • Both: variable_sub__supvariablesubsupvariable_{sub}^{sup}

  • Greek letter: alpha_1α1\alpha_{1}

  • Uppercase Greek: Delta_xΔx\Delta_{x}

  • Regular font (spaces): my_variable_my  variablemy \; variable

  • Overline: x_ovrx\overline{x}

  • Square root: value_sqrtvalue\sqrt{value}

  • Parentheses: term_prn(term)(term)

  • Prime notation: x_prmxx'

  • Infinity: T_inftyTT_{\infty}

  • Multi-part: part1_bsl_part2part1/part2part1/part2

Troubleshooting

Variable not displaying as expected?

  • Check if you're using the correct number of underscores

  • Verify the keyword is in the supported symbols list

  • Ensure no typos in placeholder keywords

Calculation errors?

  • Confirm the base name is a valid identifier

  • Check for reserved keywords conflict

  • Verify syntax without special formatting first

Last updated