We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Contour Lines

Using the function we wrote to calculate profit, we can create contour lines to show where the maximum profit is found.

This will be easier to understand if we rewrite our profit function with x for num_cakes and y for num_cookies. We'll also use the single-letter variable c for profit:

c = 5x + y

The equation can then be rearranged into the "slope-intercept" form:

y = -5x + c

What we see in the graph above is a series of contour lines following this equation, with different profit values (c). Each contour line represents the relationship between cakes (x) and cookies (y) for a given profit level.

The slope is -5, meaning that for each additional cake sold, we would need to sell 5 fewer cookies to maintain the same profit.

To maximize profit, we can start with the contour line at c = 0, then shift it to the right as far as possible while having the line touch the region that meets our constraints. The furthest valid contour line has the maximum profit as its c value, and the point where it touches the feasible region gives the relevant x (cakes) and y (cookies) values.

A few contour lines are drawn in the graph above. The minimum profit value of 0 is represented by the green line, where sales are at 0. The purple line's profit is 500, the orange line's is 1000, and the yellow line has the maximum profit value of 1300.