Gradient descent (and its mirror, gradient ascent) optimizes a multivariable function by iteratively stepping in the direction that reduces or increases the function value most steeply. Starting from an initial point x⁰, each iteration updates the current position by following the gradient scaled by a fixed step size, stopping as soon as the gradient norm falls below a convergence tolerance. The update rule is: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.
- Minimization:
x^(k+1) = x^k − α · ∇f(x^k) - Maximization:
x^(k+1) = x^k + α · ∇f(x^k)
α is the step size and ∇f is the gradient of the objective function. Symbolic differentiation is performed automatically via SymPy, so you only need to provide the expression as a string.
Endpoint
Request
The objective function as a SymPy-compatible symbolic string. Use
** for exponentiation and * for multiplication.Examples: "x**2 + y**2", "3*x**2 - 2*x*y + y**2", "x**2 + y**2 + z**2"List of variable names referenced in the expression. Must contain 2 or 3 names.Example:
["x", "y"]Initial point for the iteration. Must have the same number of elements as
variables.Example: [2.0, 3.0]Optimization direction. Either
"min" (gradient descent) or "max" (gradient ascent).The step size
α applied at each iteration. Must be strictly positive.A large step size can cause the method to diverge. If you receive a divergence error, try reducing
step_size or choosing a different initial point.Convergence threshold. The method stops when
‖∇f(x^k)‖ < tolerance. Must be in the range (0, 1].Maximum number of gradient steps before the method stops with
status: "no_convergence". Accepted range: 1–500.Response
"optimal" if the gradient norm converged below tolerance; "no_convergence" if max_iterations was reached without convergence.Coordinates of the best point found, ordered to match
variables. null only on unexpected engine failure.Function value at
optimal_point.Euclidean norm of the gradient at
optimal_point. Convergence is declared when this falls below tolerance.Total number of iterations executed.
Full iteration history. Each entry captures the state at the start of that step.
The objective expression as simplified by SymPy, confirming what was parsed.
Symbolic partial derivatives
[∂f/∂x₁, ∂f/∂x₂, …] as SymPy-formatted strings, one per variable.Echo of the variable names provided in the request, in the same order.
Human-readable summary describing the convergence outcome and the optimal point coordinates.
Expression Format
Expressions must use SymPy-compatible syntax:| Operation | Syntax | Example |
|---|---|---|
| Exponentiation | ** | x**2 |
| Multiplication | * | 3*x*y |
| Addition | + | x**2 + y**2 |
| Functions | SymPy names | sin(x) + cos(y) |
Example
Minimizef(x, y) = x² + y² starting from the point (2, 3):
Convergence Notes
Convergence is declared when
gradient_norm < tolerance. If the method reaches max_iterations without this condition being met, status is set to "no_convergence" and the best-reached point is still returned. You can increase max_iterations or decrease step_size to improve convergence.