ComfyUI > Nodes > ComfyUI-UniversalToolkit > Math Expression (UTK)

ComfyUI Node: Math Expression (UTK)

Class Name

MathExpression_UTK

Category
UniversalToolkit/Tools
Author
whmc76 (Account age: 1110days)
Extension
ComfyUI-UniversalToolkit
Latest Updated
2026-03-16
Github Stars
0.07K

How to Install ComfyUI-UniversalToolkit

Install this extension via the ComfyUI Manager by searching for ComfyUI-UniversalToolkit
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-UniversalToolkit in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Math Expression (UTK) Description

MathExpression_UTK evaluates dynamic mathematical expressions in ComfyUI for complex calculations.

Math Expression (UTK):

The MathExpression_UTK node is designed to evaluate mathematical expressions dynamically within the ComfyUI environment. This node allows you to input mathematical formulas and expressions, which it then parses and computes to produce numerical results. It supports a variety of operations, including arithmetic, comparison, and logical operations, making it a versatile tool for performing complex calculations. The node is particularly beneficial for AI artists who need to manipulate numerical data or perform calculations as part of their creative workflows. By leveraging this node, you can automate and streamline mathematical computations, enhancing the efficiency and precision of your projects.

Math Expression (UTK) Input Parameters:

expression

The expression parameter is a string that represents the mathematical formula or expression you wish to evaluate. This parameter is crucial as it defines the operations and calculations that the node will perform. The expression can include variables, arithmetic operators, comparison operators, and function calls. It is important to ensure that the expression is syntactically correct and that all variables used are defined within the context. There are no explicit minimum or maximum values for this parameter, but the expression must be valid and evaluable.

values

The values parameter is a dictionary that provides the context for the variables used in the expression. Each key in the dictionary corresponds to a variable name, and its associated value is the numerical value that the variable represents. This parameter is essential for resolving variables within the expression, allowing the node to compute the result accurately. The values can be integers or floats, and they must be finite numbers to ensure a valid computation.

Math Expression (UTK) Output Parameters:

ui

The ui output parameter provides a user interface representation of the computed result. It is a dictionary containing a key value, which holds a list with the evaluated result. This output is useful for displaying the result in a user-friendly format, making it accessible for further use or visualization within the ComfyUI environment.

result

The result output parameter is a tuple containing two elements: the integer and float representations of the evaluated expression. This output is crucial for applications that require precise numerical results, as it provides both integer and floating-point formats. The integer format is useful for scenarios where whole numbers are needed, while the float format offers precision for more detailed calculations.

Math Expression (UTK) Usage Tips:

  • Ensure that your mathematical expression is correctly formatted and that all variables are defined in the values parameter to avoid errors during evaluation.
  • Utilize the node's ability to handle complex expressions by incorporating functions and operators to perform advanced calculations efficiently.

Math Expression (UTK) Common Errors and Solutions:

Expression cannot be empty.

  • Explanation: This error occurs when the expression parameter is left blank or contains only whitespace.
  • Solution: Provide a valid mathematical expression in the expression parameter to ensure the node can perform the evaluation.

Math Expression must evaluate to a numeric result.

  • Explanation: This error arises when the evaluated expression does not result in a numeric value, such as when it evaluates to a boolean or a non-numeric type.
  • Solution: Ensure that the expression is designed to produce a numeric result, and check that all variables and operations are correctly defined.

Name not found: <variable_name>

  • Explanation: This error indicates that a variable used in the expression is not defined in the values parameter.
  • Solution: Verify that all variables in the expression are included in the values dictionary with appropriate numerical values.

Operator not supported.

  • Explanation: This error occurs when the expression contains an unsupported operator.
  • Solution: Review the expression to ensure that only supported operators are used, and modify the expression accordingly if necessary.

Math Expression (UTK) Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-UniversalToolkit
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Math Expression (UTK)