a field-theory motivated approach to computer algebra


Numeric evaluation of Cadabra expressions
Functions for evaluating Cadabra expressions given floating point values for variables

evalf(ex: Ex, values: Ex|dict) -> float

Evaluate an expression to a floating point number
evalf($x**2$, { "x": 3.0 }); evalf($a + b + c$, $a->1, b->0.5, c->-0.22$);

lambdify(ex: Ex, parameters: Ex|Iterable[Ex], constants: Ex|dict) -> Function

Create a Python function which evaluates an expression with the given parameters
If provided, any substitution rules in constants are applied before the function is 'lambdified'.
l = lambdify($\sqrt(x**2 + y**2)$, $x, y$) l(3, 4);
k = lambdify($A x**2 + B x + C$, $x$, $A -> 1, B-> 0, C -> -4$) k(2);
_create_symbol($Raux$); _create_symbol($r, R, Raux$);
{}$\big[$$r$, $R$, $Raux$$\big]$
_create_sublist($x=2, y=4$);
{x: 2.00000000000000, y: 4.00000000000000}
Copyright © 2001-2024 Kasper Peeters