Cadabra
a field-theory motivated approach to computer algebra

cdb.numeric.evaluate

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$);
\(\displaystyle{}9.0\)
\(\displaystyle{}1.28\)

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);
5.0
k = lambdify($A x**2 + B x + C$, $x$, $A -> 1, B-> 0, C -> -4$) k(2);
0.0
_create_symbol($Raux$); _create_symbol($r, R, Raux$);
\(\displaystyle{}Raux\)
{}$\big[$$r$, $R$, $Raux$$\big]$
_create_sublist($x=2, y=4$);
{x: 2.00000000000000, y: 4.00000000000000}
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science