Universe

Kalt evaluates arbitrary nested equations and removes the need to transcribe your equations into the default calc system. You will no longer run into unsupported operations, and it all works for scalars and matrices. Since everything runs on normal content, you can store and adjust the results as needed.

Complex equation?

complex equation

$comp(frac(binom(2, 5) (1 + 3 i)^4.3 (2 - 3 i)^(2-5) 5!, sqrt((3+4i)(3-4i))) dot mat(
    1+i, 2, 0;
    0, 3-i, 0;
    0, 5, 7+i;
) dot vec(1, 2, 3))$

complex equation result

No problem :D

Import and start evaluating

#import "@preview/kalt:0.1.0": comp;

Math Operators

  • +, -, /, *|dot
  • ^ exponents
  • ! factorial
  • root, sqrt
  • binom
#let N = 2
$comp(sqrt((3+i)!)) dot pi/(e + 2.3^(#N))$

evaluation of equation

Number Formats

$comp("2.1e3"+1)$ // => 2101.0
$comp("0b010"*2)$ // => 4.0
$comp("0XFF"i/2)$ // => 127.5i

Built-in Functions

  • ln, log_a
$comp(ln(2^4))$ // => 4.0

Complex Numbers

Full support for complex numbers at any position in an equation.

$comp(e^(i pi))$ // => -1

Matrices and Vectors

$comp(mat(1/i+2, 0)^T dot mat(1, 2))$ // => mat(2-i, 4-2i; 0, 0)

Indexing

Subslice your matrices the way you are used to from NumPy ndarrays.

$comp(mat(1,2;4,5)[::, 1])$ // => mat(2; 5)
$comp(mat(1,2,3;4,5,6)[1:2:, [2,1]])$ // => mat(6, 5)

Element-wise Operations and Mapping

Element-wise multiplication is supported by default:

#let m = $mat(1,2,3;4,5,6)$
$comp(#m compose #m)$ // => mat(1, 4, 9; 16, 25, 36)

You can also apply custom mapping functions to each element in Typst

#import "@preview/kalt:0.1.0": comp, map;

$map(mat(2, 2; 2, 6), #{ a => $#a + 3$ })$ // mat(5, 5; 5, 9)

Or merge multiple matrices together:

#import "@preview/kalt:0.1.0": comp, merge;

$merge(#{ (a, b) => $log_#a (#b)$ }, mat(2, 2; 2, 2), mat(2, 2; 2, 8))$ // => mat(1, 1; 1, 3)

Error Handling

It returns inlined error messages for mistakes. error reporting

Development

You do not need to move everything into Kalt. Kalt uses sertyp to run the heavy computation in Rust using Wasm. The backend libraries for both sertyp and kalt are available as standalone libraries and are ready for your project :D Basic math should stay in kalt, though. For more on what still needs work, take a look at the contributions section.

Contributions

There is still a lot to do. Many basic functions like abs, floor, and ceil are not yet supported. Quality-of-life features like improved floating point formatting would brighten everyone’s day. If you find something that is missing, feel free to contribute :D