Optimization
Closed-Interval Optimization
Find absolute extrema of a differentiable function by testing critical points and both endpoints.
optimize(x^2-6*x+5,x,0,5) differentiates to 2*x-6. The only critical point in [0, 5] is x=3, where f(3)=-4. The endpoints are f(0)=5 and f(5)=0, so the absolute minimum is -4 at x=3 and the absolute maximum is 5 at x=0.
maximize(x*(10-x),x,0,10) has maximum 25 at x=5 and endpoint values 0. minimize(x^2+4*x+7,x,-5,5) has minimum 3 at x=-2 and maximum 52 at x=5. minimize of x^2-6*x+5 still reports -4 at x=3. optimize(x^3-3*x,x,-2,2) attains 2 at both x=-1 and x=2, and -2 at both x=1 and x=-2. optimize(5,x,0,3) is constant, so every point of the interval is an absolute minimum and an absolute maximum.
Equation
optimize(x^2-6*x+5,x,0,5)
Critical points, endpoints, and attained extrema
A single-variable optimization problem asks for the largest or smallest value of a function on an interval. The solver differentiates with the existing derivative routine, solves f'(x)=0, and also keeps points where the derivative does not exist but the function does, such as the corner of abs(x). Every candidate inside the feasible domain is evaluated together with the included endpoints. On a closed bounded interval where the function is continuous, the extreme-value theorem says the absolute maximum and minimum are among those candidates.
An open end is not automatically a maximum or a minimum. If the function only approaches a finite bound, that bound is a supremum or an infimum and the result says it is not attained. Infinity is never treated as a point that is attained. A constant function is both an absolute maximum and an absolute minimum at every feasible point. The geometric commands rectangle_max_area, rectangle_min_perimeter, open_box_max_volume, and min_surface_area build one objective, a constraint, and a feasible domain, then call the same solver. They do not read an arbitrary word problem.
Reading the input
optimize(x^2-6*x+5,x,0,5)— This is a command. The name selects the routine, and the items inside the parentheses are its arguments.
Other versions of this example
These stay on this page so each version keeps the same explanation. Choose Try example to run a version in its Studio workflow, or copy it into the editable field below.
Quadratic on [0, 5]
Absolute minimum -4 at x=3 and absolute maximum 5 at x=0.
optimize(x^2-6*x+5,x,0,5)
Maximize a product
Maximum 25 at x=5. Both endpoint values are 0.
maximize(x*(10-x),x,0,10)
Minimum on [-5, 5]
The minimum is 3 at x=-2. The maximum on [-5, 5] is 52 at x=5.
minimize(x^2+4*x+7,x,-5,5)
Minimize the quadratic
The minimum is still -4 at x=3, and the maximum 5 at x=0 is reported too.
minimize(x^2-6*x+5,x,0,5)
Several extrema
Absolute maximum 2 at x=-1 and x=2. Absolute minimum -2 at x=1 and x=-2.
optimize(x^3-3*x,x,-2,2)
Constant function
Every point of [0, 3] is both an absolute minimum and an absolute maximum.
optimize(5,x,0,3)
Try a change
- Edit one number in the field, then use Solve Equation. The studio opens on the homepage with the edited text and runs it.
- Use Open in DGS Studio when you want the expression loaded but not run yet.
Solve Equation shows the objective, the first derivative, the critical points, the endpoint values, and whether each extreme is attained. An open bound that is not reached is a supremum or an infimum.