ComfyUI Node Runs on cloud

Square root

√A as a node, with both roots on the outputs

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
Square root
    • FLOAT
    • FLOAT
    Value1.00

    Square root does what it says - takes a number and gives you √A. The small twist worth knowing is that it exposes two outputs, because every positive number technically has two square roots: a positive one and its negative mirror. Most of the time you'll grab the first. But the second is there if the math you're building actually needs the negative branch.

    How it works

    You feed it a value and it computes the square root. The two FLOAT outputs are the positive root and its negative counterpart (e.g. for 9 you get 3 and -3). If you only ever wanted the ordinary answer, just wire the first output and ignore the second.

    The inputs and outputs that matter

    • Value (FLOAT, default 1) - the number to root. Feed it from another node; the default of 1 roots to 1, so a fresh node does nothing until wired.
    • Outputs: FLOAT and FLOAT - the positive root and the negative root. Grab the first for normal use; the second exists for the cases where you need the negative branch.

    Where it fits

    Square root shows up whenever you're reasoning about area versus side length. If you know a total pixel budget and want the side of the square that fits it, that's a square root. In Derfuu-style dimension math it pairs naturally with Power (the general exponent node), Multiply, and Divide to build a formula that derives one dimension from another. Follow it with Ceil or Floor to land on a whole-number pixel size.

    How to install it

    ComfyUI Manager: search Derfuu_ComfyUI_ModdedNodes, install, restart. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes
    

    then restart. No dependencies, no models - it's plain Python.

    Common issues & troubleshooting

    You grabbed the negative output by mistake. There are two, and they look identical in the node. If your downstream value is unexpectedly negative, you probably wired the second (negative-root) output - switch to the first.

    Negative input errors or returns NaN. The square root of a negative number isn't a real number. If the value feeding in could go below zero, run it through Absolute value first.

    You needed a general power, not a root. For cube roots or arbitrary exponents, use the Power node with a fractional exponent (1/3 for a cube root) - this node only does the square root.

    Node is red after a pack update. Derfuu has deleted deprecated nodes on updates rather than keeping them around labeled as old, so old workflows can reference names that no longer exist. Replace with a current copy. A ModuleNotFoundError mentioning Derfuu_ComfyUI_ModdedNodes_legacy means a duplicated folder - keep exactly one, named Derfuu_ComfyUI_ModdedNodes.

    CategoryDerfuu_Nodes/Math

    Inputs (1)

    NameTypeDefaultDescription
    ValueFLOAT1.00

    Outputs (2)

    NameTypeDescription
    FLOATFLOAT
    FLOATFLOAT