eval

eval(expression)

Evaluates an expression and returns the result as double.

Parameters:

expression (str) – symbolic expression to evaluate

Return type:

float

Returns:

numeric value of the expression

NOTE: This function does not perform rigorous input validation! It uses nothing but the MAD-X builtin rather incompetent error checks. This means invalid input such as ‘+’ can lead to program crashes! If you’re looking for more secure validation, see cpymad.util.check_expression().