Hello! With the creator of the symbolica, a powerful CAS (Computer Algebra System) used in active research, we have worked to get a wasm plugin working.
This means that you can now use the full power of symbolica directly inside of your typst documents.
For example you can factor polynomials, or take derivatives, and then numerically evaluate,
#import "@preview/symbolica:0.1.0": *
#let x = symbol("x")
#let f = math($x^4 - 5 x^2 + 4$)
$
f(x) &= #to-typst(f) \
&= #to-typst(factor(f)) \
f'(x) &= #to-typst(derivative(f, x))
$
#evaluate(f,values:((x,1.2),))
You can solve (non-linear) systems of equations,
#import "@preview/symbolica:0.1.0": *
#let solutions = solve(
($x^2 + y^2 - a$, $x - 2y - b$).map(math),
($x$, $y$).map(math),
domain: "real",
)
#let (x, y) = solutions.branches.first().values.map(to-typst)
$ x = #x, quad y = #y $
And automatically integrate using RUBI
#import "@preview/symbolica:0.1.0": *
#let x = math($x$)
#let f = math($x / (x + 1)$)
#to-typst(integrate(f, x))
Since it is a full CAS, you can of course do standard things like replacement rules. I envision this as a really neat way to expose mathematical thinking. Usually when you write out a derivation, you write the state of the equation after each transformation.
You might say that you first distribute, then show the expanded expression. Then you isolate a variable, or re-express a sub-part of your expression by a definition.
All these transformations are replacement rules, and now you can write out the operation, not the states in between! This eliminates typos, makes repeating the calculation or derivation on a different input trivial, and also makes you reflect on what you’re actually doing!
Feedback, issues and comments are really appreciated!