PanPhyPlotMath reference
Manual

PanPhyPlot · Formula guide

A little math for your data

Find the syntax you need for a formula column, from a simple square to the mean of repeat readings.

Working on a fit? See custom fit syntax.

Start here

Write your first formula

  1. Choose Data → Formula in the app’s toolbar.
  2. Use a column letter, such as B^2, or a unique column name, such as T^2. No leading = is needed.
  3. Check the result preview, give the new column a name and unit, then choose Apply.
Reading the examples

A and B below mean column A and column B in the same row. Replace them with the letters or names in your own sheet. Formula columns update when the source data changes.

Build an expression

Operators

Write multiplication explicitly with *, and use parentheses to control the order of calculation.

Arithmetic operators and examples
Operator Meaning Example
+ Add A + B
- Subtract / negative sign A - B, -A
* Multiply 2*A
/ Divide B/A
^ Power A^2, B^0.5
% Remainder (mod) A % 2
( ) Group parts of an expression (A + B)/2

Transform a reading

Functions

Put the input inside parentheses: sqrt(B) takes the square root of each value in column B.

Trigonometry

Angles are in radians. For degrees, convert first: sin(A*pi/180).

Trigonometric functions
Function Meaning Example
sin(A) Sine sin(A)
cos(A) Cosine cos(A)
tan(A) Tangent tan(A)
asin(A), acos(A), atan(A) Inverse trig atan(B/A)

Powers, roots and absolute value

Roots and absolute value
Function Meaning Example
sqrt(A) Square root sqrt(A)
cbrt(A) Cube root cbrt(B)
abs(A) Absolute value abs(B)

Logs and exponentials

Logarithms need a positive input. A real square root needs a non-negative input.

Logarithms and exponentials
Function Meaning Example
log(A) Natural log (base e) log(B)
log10(A) Base-10 log log10(B)
exp(A) e^A exp(A)

Rounding

Rounding functions
Function Meaning Example
round(A) Round to nearest integer round(3.6) gives 4
floor(A) Round down floor(3.9) gives 3
ceil(A) Round up ceil(3.1) gives 4

Repeat readings

Functions for readings in the same row
FunctionMeaningExample
meanArithmetic meanmean(B, C, D)
medianMiddle readingmedian(B, C, D)
min, maxSmallest or largest readingmax(B, C, D)
halfspreadHalf the range (at least two readings)halfspread(B, C, D)

These five functions leave out blank readings among their inputs. Other expressions stay blank when a required input is missing or invalid.

Values you can use

Constants

Mathematical constants
Constant Value (approx.) Example
pi 3.14159... 2*pi*A
e 2.71828... e^A or exp(A)
tau 6.28318... (2*pi) tau*A
Case matters

Use lowercase pi and e. Column letters take priority: E refers to column E when it exists, so use e or exp(A) for Euler’s number.

Try it on your sheet

Formula ideas

Use these expressions in Data → Formula, replacing the column letters as needed.

Reciprocal
1/AA must not be zero.
Square
A^2Useful for a period-squared graph.
Square root
sqrt(B)Use non-negative values.
Natural log
log(B)Use positive values.
Mean of repeats
mean(B, C, D)Combine readings from the same row.
Magnitude
abs(B)Remove the sign of a reading.
Sine wave
sin(2*pi*A)One cycle per unit of A.
Average two columns
(A+B)/2Both readings must be present.

In the fit inspector

Custom fit syntax

A custom fit uses x for the independent variable and parameter names such as a and b. For a straight line, enter a*x+b. The operators, trig, roots, logs and rounding syntax above work here too.

See fit types and custom formulas in the manual →

Formula not working?

Check spelling and capitalization, column names and parentheses. Use * for multiplication. A formula column needs a finite real result; division by zero or an out-of-range input leaves the result blank.

A quick reference to the Math.js syntax used by PanPhyPlot.