formula

Basic data handling: MathFormula

A node that evaluates a mathematical formula provided as a string without using eval. This node takes an arbitrary number of numerical inputs (single letters like `a`, `b`, `c`, etc.) and safely evaluates the formula with supported operations: +, -, *, /, //, %, **, parentheses, and mathematical functions. NOTE on Operator Precedence: This parser uses standard precedence rules. Unary minus binds tightly, so expressions like `-a ** 2` are interpreted as `(-a) ** 2`. To calculate `-(a ** 2)`, use parentheses: `-(a ** 2)`. The identifiers `e` and `pi` are special. When used as a function call (`e()`, `pi()`), they return their respective mathematical constants. When used as a variable (`e`), they expect a corresponding input. Supported functions: - Basic: abs, floor, ceil, round, min(a,b), max(a,b) - Trigonometric: sin, cos, tan, asin, acos, atan, atan2(y,x), degrees, radians - Hyperbolic: sinh, cosh, tanh, asinh, acosh, atanh - Exponential & Logarithmic: exp, log, log10, log2, sqrt, pow(base,exp) - Constants (must be called with empty parentheses): pi(), e()

Pack: Basic data handling

custom_nodes.ComfyUI-basic_data_handling

Inputs (2)

NameTypeRequired
formulaSTRINGrequired
aFLOAT,INToptional

Outputs (1)

NameType
FLOATFLOAT