{ "hash": "73efc2e9657f02c4ba245847cafcd6e9", "result": { "markdown": "# Optimization\n\n\n\nThis section uses these add-on packages:\n\n``` {.julia .cell-code}\nusing CalculusWithJulia\nusing Plots\nusing Roots\nusing SymPy\n```\n\n\n\n\n---\n\n\nA basic application of calculus is to answer questions which relate to the largest or smallest a function can be given some constraints.\n\n\nFor example,\n\n\n> Of all rectangles with perimeter $20$, which has of the largest area?\n\n\n\nThe main tool is the extreme value theorem of Bolzano and Fermat's theorem about critical points, which combined say:\n\n\n> If the function $f(x)$ is continuous on $[a,b]$ and differentiable on $(a,b)$, then the extrema exist and must occur at either an end point or a critical point.\n\n\n\nThough not all of our problems lend themselves to a description of a continuous function on a closed interval, if they do, we have an algorithmic prescription to find the absolute extrema of a function:\n\n\n1. Find the critical points. For this we can use a root-finding algorithm like `find_zero`.\n2. Evaluate the function values at the critical points and at the end points.\n3. Identify the largest and smallest values.\n\n\nWith the computer we can take some shortcuts, as we will be able to graph our function to see where the extreme values will be, and in particular if they occur at end points or critical points.\n\n\n## Fixed perimeter and area\n\n\nThe simplest way to investigate the maximum or minimum value of a function over a closed interval is to just graph it and look.\n\n\nWe began with the question of which rectangles of perimeter $20$ have the largest area? The figure shows a few different rectangles with this perimeter and their respective areas.\n\n::: {.cell cache='true' hold='true' execution_count=4}\n\n::: {.cell-output .cell-output-display execution_count=5}\n```{=html}\n
Some possible rectangles that satisfy the constraint on the perimeter and their area.
\n