Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/FabianeloV/Metodo-simplex/llms.txt

Use this file to discover all available pages before exploring further.

The graphical method for multivariable functions locates and classifies the critical points of an unconstrained objective function by solving ∇f(x) = 0 numerically. Rather than relying on sympy.solve (which can hang or return parametric solution sets for non-polynomial expressions), the engine uses multivariate Newton’s method seeded from a grid of starting points inside the user-supplied bounds:
x^(k+1) = x^k − H(x^k)⁻¹ · ∇f(x^k)
Each discovered critical point is then classified by inspecting the eigenvalues of the Hessian: all positive → minimum, all negative → maximum, mixed signs → saddle, near-zero eigenvalue → degenerate. In addition to critical-point analysis, the endpoint returns grid data ready to render in Plotly — a surface mesh for 2-variable functions or a 3D volume scatter for 3-variable functions.

Endpoint

POST /api/v1/gradient/graphical

Request

expression
string
required
The objective function as a SymPy-compatible symbolic string. Use ** for exponents and * for multiplication.Examples: "x**2 + y**2", "x**3 - 3*x + y**2 - 2*y"
variables
string[]
required
List of variable names used in the expression. Must contain 2 or 3 names.Example: ["x", "y"]
bounds
number[][]
required
Search domain for each variable, as a list of [min, max] pairs — one per variable, in the same order as variables.Example: [[-5, 5], [-5, 5]]
Every bound must satisfy max > min. The number of bounds must equal the number of variables. Critical points found outside the domain are discarded; only the visualization grid is clipped to the domain.
goal
string
required
Which type of critical point to treat as the optimum: "min" or "max". If no matching critical point is found inside the domain, the closest available critical point is returned instead and status is set to "no_critical_point".

Response

status
string
"optimal" if a critical point whose nature matches goal was found inside the bounds; "no_critical_point" otherwise (the engine may still return the best available critical point with a different nature).
variables
string[]
Echo of the variable names from the request.
function_str
string
The expression as parsed and simplified by SymPy.
optimal_point
number[] | null
Coordinates of the best critical point found, ordered to match variables. null if no critical points were located inside the domain.
optimal_value
number | null
Function value at optimal_point.
critical_points
CriticalPointSchema[]
All distinct critical points found within the domain, each with its classification.
surface
SurfaceData | null
Present only for 2-variable functions. Contains a 60×60 evaluation grid over the domain for rendering a 3D surface or contour plot in Plotly.
volume
VolumeData | null
Present only for 3-variable functions. Contains a 25×25×25 scattered point cloud for rendering an isosurface or volume in Plotly.
message
string
Human-readable summary of the outcome, including the optimal point coordinates, its nature, and the function value.

Visualization Layout

Variable countsurfacevolumeRecommended Plotly trace
2✓ presentnullSurface or Contour
3null✓ presentVolume or Isosurface
surface is always null for 3-variable functions, and volume is always null for 2-variable functions. Check variables.length in the response before accessing either field.

Example

Find the minimum of f(x, y) = x² + y² over the domain [-5, 5] × [-5, 5]:
curl -X POST https://api.example.com/api/v1/gradient/graphical \
  -H "Content-Type: application/json" \
  -d '{
    "expression": "x**2 + y**2",
    "variables": ["x", "y"],
    "bounds": [[-5, 5], [-5, 5]],
    "goal": "min"
  }'
Response:
{
  "status": "optimal",
  "variables": ["x", "y"],
  "function_str": "x**2 + y**2",
  "optimal_point": [0.0, 0.0],
  "optimal_value": 0.0,
  "critical_points": [
    {
      "point": [0.0, 0.0],
      "value": 0.0,
      "nature": "min"
    }
  ],
  "surface": {
    "x": [-5.0, -4.830508..., ..., 5.0],
    "y": [-5.0, -4.830508..., ..., 5.0],
    "z": [[50.0, 48.33..., ...], ...]
  },
  "volume": null,
  "message": "Se encontró un mínimo local en (x = 0, y = 0) con f = 0."
}

Critical-Point Classification Details

Critical points are found by running Newton’s method from a uniform grid of seed points inside the domain (6 seeds per axis for 2-variable functions, 4 per axis for 3-variable functions). Duplicate roots are removed by rounding coordinates to 5 decimal places. Classification uses the eigenvalues of the symbolic Hessian:
Eigenvalue patternnature
All λ > 0"min"
All λ < 0"max"
Mixed signs"saddle"
Any |λ| < 1e-6"degenerate"
The method uses a fixed seed grid, so critical points that lie very close to the boundaries of the domain, or functions with many local optima, may not all be discovered. Widen the bounds or increase the resolution if you suspect missed roots.

Build docs developers (and LLMs) love