This builds on top of the zero package. And adds all of the commonly used math operations from the calc namespace.
#import "@preview/zero:0.7.0": *
#import "@preview/zero-calc:0.7.0": *
#zcalc.div(zi.m[30+-0.3], zi.s[5+-0.4])
![]()
zcalc.div divides the first argument by the second argument, all the uncertainty is automatically calculated and updated, the units are converted accordingly to m/s and the significant figures are preserved.
All operations carry their calculation history, which can be displayed. This way you can automatically typeset your method as well as your uncertainty propagation.
#let value = zcalc.div(m[30+-1.45], s[5.0+-0.20])
#let value = zcalc.pow(value, 2)
#display.method-result(value)
#display.error-method-result(value)
Equations can also be written in math mode and are automatically converted to a function using parseley behind the scenes:
#let kinetic-energy-math = $E_"kin" = 1/2 m v^2$
#let kinetic-energy-function = equation.define(kinetic-energy-math)
#let value = kinetic-energy-function(m: g[10], v: zcalc.div(m[30], s[5.0]))
#kinetic-energy-math
#display.method-result(value)
There is also some rudimentary support for manipulating these equations, such as isolating variables in simple equations:
#let kinetic-energy-tree = equation.to-tree(kinetic-energy-math)
#let velocity-tree = equation.isolate-variable(kinetic-energy-tree, $v$)
#display.display-equation(velocity-tree.first())
#equation.calculate-tree(velocity-tree, m: g[10], Ekin: g-m2-s-2[180])
This package was written without AI assistance, but nevertheless it’s not perfect and there may still be bugs or unexpected behaviour. Since people might rely on this package it’s important that it’s 100% scientifically and mathematically correct, so I would appreciate if someone could take a look or stress test it. If someone is interested in writing a better solver for the equations that would also be useful, but I’m happy enough with the current implementation. In general feedback on the intuitive-ness of the API is also welcome and I’d prefer to make changes before releasing it on the universe.


