{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.calculatorx.com/schemas/math.numerical.root.input.json",
  "title": "Numerical root — input",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "method": {
      "type": "string",
      "enum": [
        "newton",
        "newton_raphson",
        "newton-raphson",
        "bisection",
        "binary",
        "secant"
      ]
    },
    "integrand": {
      "type": "string",
      "enum": [
        "poly",
        "polynomial",
        "sin",
        "exp",
        "e^x"
      ]
    },
    "coeffs": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 2,
          "maxItems": 9
        }
      ],
      "description": "c0,c1,…,cn constant first; not all zero"
    },
    "coefficients": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 2,
          "maxItems": 9
        }
      ],
      "description": "Alias of coeffs; c0,c1,…,cn constant first; not all zero"
    },
    "x0": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    },
    "x1": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    },
    "a": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    },
    "b": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    },
    "tol": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Positive finite parsed value; default 1e-10. Polynomial scaled residual, sine absolute residual, or bisection absolute bracket half-width; not a root-position guarantee."
    },
    "max_iter": {
      "oneOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Parsed value must be an integer from 1 to 100; default 50. Decimal text is validated after parsing."
    },
    "mode": {
      "type": "string",
      "enum": [
        "newton",
        "newton_raphson",
        "newton-raphson",
        "bisection",
        "binary",
        "secant"
      ],
      "description": "Legacy alias of method; supplied aliases must agree."
    },
    "f": {
      "type": "string",
      "enum": [
        "poly",
        "polynomial",
        "sin",
        "exp",
        "e^x"
      ],
      "description": "Legacy alias of integrand; supplied aliases must agree."
    },
    "guess": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    },
    "lo": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    },
    "hi": {
      "oneOf": [
        {
          "type": "number"
        },
        {
          "type": "string",
          "pattern": "^\\s*[+\\-−–—]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+\\-]?[0-9]+)?\\s*$"
        }
      ],
      "description": "Finite binary64 decimal; nonzero-to-zero underflow is NUMERIC_UNDERFLOW. Other binary64 rounding is permitted."
    }
  },
  "allOf": [
    {
      "anyOf": [
        {
          "properties": {
            "integrand": {
              "enum": [
                "sin",
                "exp",
                "e^x"
              ]
            }
          },
          "required": [
            "integrand"
          ]
        },
        {
          "properties": {
            "f": {
              "enum": [
                "sin",
                "exp",
                "e^x"
              ]
            }
          },
          "required": [
            "f"
          ]
        },
        {
          "required": [
            "coeffs"
          ]
        },
        {
          "required": [
            "coefficients"
          ]
        }
      ]
    },
    {
      "if": {
        "anyOf": [
          {
            "properties": {
              "method": {
                "enum": [
                  "bisection",
                  "binary"
                ]
              }
            },
            "required": [
              "method"
            ]
          },
          {
            "properties": {
              "mode": {
                "enum": [
                  "bisection",
                  "binary"
                ]
              }
            },
            "required": [
              "mode"
            ]
          }
        ]
      },
      "then": {
        "allOf": [
          {
            "anyOf": [
              {
                "required": [
                  "a"
                ]
              },
              {
                "required": [
                  "lo"
                ]
              }
            ]
          },
          {
            "anyOf": [
              {
                "required": [
                  "b"
                ]
              },
              {
                "required": [
                  "hi"
                ]
              }
            ]
          }
        ]
      },
      "else": {
        "anyOf": [
          {
            "required": [
              "x0"
            ]
          },
          {
            "required": [
              "guess"
            ]
          }
        ]
      }
    },
    {
      "if": {
        "anyOf": [
          {
            "properties": {
              "method": {
                "const": "secant"
              }
            },
            "required": [
              "method"
            ]
          },
          {
            "properties": {
              "mode": {
                "const": "secant"
              }
            },
            "required": [
              "mode"
            ]
          }
        ]
      },
      "then": {
        "required": [
          "x1"
        ]
      }
    }
  ],
  "description": "Newton, bisection, or secant for an approximate real zero of a polynomial or sin. exp has no finite real zero and returns NO_CONVERGENCE. Discovery /nonlinear-equation. Not the nth-root page, not CAS, not a system. (calculation_version 1.1.6) Provide at least 1 of: coeffs, coefficients, integrand."
}
