DGS Studio

Optimization

Optimization on an Interval

Plot a quadratic on a closed interval with its critical point, endpoint values, and absolute extrema.

Generate Graph draws optimize(x^2-6*x+5,x,0,5) on the existing board. The interval [0, 5] is shaded, the curve is bright inside that interval, and the points show the absolute minimum -4 at x=3, the absolute maximum 5 at x=0, and the local maximum 0 at x=5.

The same board shows maximize(x*(10-x),x,0,10) and minimize(x^2+4*x+7,x,-5,5), whose minimum is 3 at x=-2 and whose maximum is 52 at x=5. It also shows the corner of abs(x) on [-2, 2], the two absolute extrema of x^3-3*x on [-2, 2], and the open interval (0, 1) where the unattained bounds are hollow markers. Zoom, pan, and the existing graph export stay on this board.

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

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.

Closed quadratic

Absolute minimum -4 at x=3 and absolute maximum 5 at x=0.

optimize(x^2-6*x+5,x,0,5)

Maximum product

The maximum is 25 at x=5. Both endpoints are 0.

maximize(x*(10-x),x,0,10)

Minimum on [-5, 5]

The minimum is 3 at x=-2. The maximum is 52 at x=5.

minimize(x^2+4*x+7,x,-5,5)

Absolute value

The minimum is the corner at x=0. The maximum is 2 at both endpoints.

optimize(abs(x),x,-2,2)

Two extrema

The absolute maximum 2 is attained at x=-1 and x=2.

optimize(x^3-3*x,x,-2,2)

Open interval

On (0, 1) the infimum 0 and supremum 1 are not attained.

optimize(x^2,x,0,1,open)

Try a change

Generate Graph draws the objective and the optimization interval on the existing board, with distinct labels for local and absolute extrema. A geometric example adds an interactive figure outside the exported graph. Zoom, pan, and export stay available.

Edit and generate

Generate Graph opens the studio homepage and runs this field. Open in DGS Studio loads the same text and waits for you to generate it. The equation is sent once, as a query parameter.

Related examples