Enter your values
Set up your model
Optimize a nonlinear function of two real variables over a bounded region.
Use x, y, numbers, parentheses, + − × ÷, powers, and sin, cos, tan, exp, ln, sqrt, or abs. Trigonometric functions use radians.
Nonlinear constraints
Enter one relation per row, such as x² + y² ≤ 25.
Search bounds
The solver searches this rectangle; bounds are part of the model.
What is a nonlinear programming calculator?
Nonlinear programming optimizes an objective function when the objective, one or more constraints, or both are nonlinear. This calculator searches a bounded region in two real variables and reports a numerical estimate.
Important terms
- Objective function
- The function f(x,y) whose value is minimized or maximized.
- Feasible region
- The points satisfying every constraint and lying within the entered search rectangle.
- Local optimum
- A point that is better than nearby feasible points; another region may contain a better point.
- Global optimum
- The best feasible value over the entire modeled region. A numerical search alone does not prove global optimality.
When this method is useful
- Explore nonlinear cost, energy, or error functions with two decision variables.
- Visualize how constraints clip a two-dimensional objective landscape.
- Compare local numerical candidates before applying a rigorous optimization method.
Formula and variables
- f(x,y)
- The real-valued objective function.
- x, y
- The two real decision variables.
- gᵢ(x,y) ≤ 0
- An inequality constraint defining part of the feasible region.
- hⱼ(x,y) = 0
- An equality constraint; narrow equality sets can be missed by a sampled search.
- D
- The feasible points inside the entered rectangular bounds.
The calculator samples a rectangular grid, keeps finite points that satisfy all constraints, and then refines the best sampled point by checking its neighbors at smaller step sizes. This is useful for exploration, but it is not a global optimization proof.
Domain note: This educational solver supports two real variables, bounded search ranges, up to eight nonlinear constraints, and a safe expression parser. Supported functions include trigonometric, inverse trigonometric, exponential, logarithmic, hyperbolic, square-root, and absolute-value functions. Trigonometric inputs use radians. Narrow feasible regions, equality curves, singularities, and separated local optima may be missed.
How to use this calculator
- 1
Choose whether to minimize or maximize the objective f(x,y).
- 2
Enter an objective using x, y, supported arithmetic, powers, parentheses, and listed functions.
- 3
Add each constraint as an expression compared with another expression, for example x^2+y^2<=25.
- 4
Set finite minimum and maximum bounds for x and y. These bounds define the rectangular search domain.
- 5
The calculator samples points, filters them by the constraints, and keeps the best finite feasible value.
- 6
A local neighbor search refines that candidate. Review the plot and treat the answer as an estimate, not a certified global optimum.
Step-by-step examples
Example 1
Problem: Minimize f(x,y) = (x − 2)² + (y − 1)² subject to x² + y² ≤ 25, with −4 ≤ x,y ≤ 4.
Substitution: The objective is a sum of squares, so its smallest possible value is 0. At (x,y)=(2,1), the constraint gives 2²+1²=5≤25 and the objective gives (2−2)²+(1−1)²=0.
Result: The minimum is f(2,1)=0 at (2,1).
The point (2,1) is feasible and reaches the absolute lower bound of a sum of squares. A numerical search should return a point close to this exact solution.
Example 2
Problem: Maximize f(x,y)=10−(x−1)²−2(y+1)² over −4≤x,y≤4.
Substitution: Both squared terms are nonnegative, so f(x,y)≤10. At (1,−1), both are zero and the point is inside the bounds.
Result: The maximum is f(1,−1)=10.
This smooth concave objective has its peak at (1,−1); the bounded search should find a close numerical estimate.
Rules, edge cases, and related ideas
Constraints define what is allowed
An objective value matters only at a feasible point. Every entered relation must hold at the candidate.
Bounds make the search finite
The rectangular x and y limits restrict the candidate domain. An optimum outside those limits is not considered.
Numerical search is exploratory
Grid resolution and local refinement can locate useful candidates, but a nonconvex problem may have several local optima or narrow feasible regions.
Edge cases and limitations
- A narrow feasible region may not contain any sampled grid point, even if feasible points exist between grid locations.
- An equality constraint describes a thin curve or set and may be missed by grid sampling; reformulate or use a dedicated constrained solver when possible.
- Functions such as sqrt or ln are evaluated only where their real-valued domains are valid.
- A nonconvex objective can have multiple local optima, and this search does not prove which is globally best.
- If no finite feasible sample is found, inspect the expressions, function domains, constraints, and search bounds.
How this differs from a related concept
Linear programming optimizes a linear objective over linear constraints and has specialized geometric methods. Integer programming adds whole-number restrictions. Nonlinear programming allows curved objectives or feasible regions, so a general problem may have local optima, difficult domains, and no simple corner-point solution.
Understand the result
The reported point is the best candidate found by the bounded grid and local refinement. Check that the bounds include the region of interest and that the plot matches the constraints. For a result that must be proven globally, use analytical methods or a solver with certified global optimization.
Common mistakes
- Entering a relation without a comparison operator, such as <=, >=, or =.
- Choosing search bounds that exclude the desired optimum.
- Assuming the best sampled point proves global optimality.
- Using degrees for trigonometric expressions; this calculator interprets angles in radians.
- Expecting a very narrow equality curve or feasible pocket to be captured by a finite grid.
Frequently asked questions
What does a nonlinear programming calculator do?
It searches for a minimum or maximum of an objective when the objective or constraints can be nonlinear. This version explores bounded problems in two real variables.
Is the returned answer exact?
No. It is a numerical estimate from grid sampling followed by local refinement. The displayed value is rounded for readability.
Does it guarantee a global optimum?
No. Nonconvex models can have multiple local optima, and a finite sampled search cannot certify the global best value.
Why enter search bounds?
Bounds define the rectangle being searched and make the numerical search finite. A solution outside those limits will not be considered.
Can it handle equality constraints?
You can enter equality relations, but a grid may miss a thin equality set. Use a different parameterization or a dedicated solver if the equality is essential.
Which functions and variables are supported?
The objective and constraints can use x and y, arithmetic, powers, parentheses, and supported real functions including sin, cos, exp, ln, sqrt, and abs. Trigonometric functions use radians.