Finding Intervals of Increase/Decrease and Concavity In this example, we demonstrate the use of Calculus and technology to graphically analyze functions. We wish to analyze the graph of y = 2x^7 - 21x^6 - 36x^5 + 3x^4 -38x^3 + 24x^2. First, as always, we import our symbolic package into Python, then define x as a symbolic variable using the symbols command, then define our expression y. Let’s first just plot the graph in a standard “calculator window” (domain and range of [-10,10]). To do this, we first enter our command matplotlib notebook so the graph appears in the Jupyter notebook, then use the plot command with the domain in a tuple and the range using the ylim option. From this graph, it appears that there is one local minimum and one local maximum. Now let’s regraph this in the same domain, but using the default range. As you can see, this is even less helpful since you cannot even see the local extrema from the first graph. So we will use calculus to determine the intervals where the graph is increasing or decreasing. The steps to do this by hand are: 1) Find the derivative of the function (diff) 2) Find the critical values by solving where the derivative is zero (solve) 3) Determine the sign of the derivative in each subinterval around the critical values. We can do this in Python either graphically (plot) or numerically substituting values (subs) . We will call our derivative dy, and we’ll print the result at each step in case we need to debug our code. We will call the critical values cvals. When we print the critical values, we notice only one of them makes practical sense, so we trying to convert the list to floating point decimals using evalf along with list comprehension. So we define cvalsapprox equal to the list of cvals[i].evalf() for i in the range from 0 to 5 (remember that is 0 inclusive to 6 exclusive). After a short computational pause, we see there are 4 real critical values-including one outside our original domain-and 2 complex values which we ignore. Now we’ll plot the derivative in a domain containing all the critical values and a small range to examine the signs (above or below the x-axis). When we do, we see the derivative is positive from (-oo, -1.625), (0, 0.35), and (10.253, oo), while the derivative is negative from (-1.625, 0) and (0.35, 10.253). If it is not obvious from the graph, we can create a list of test values and substitute them into the derivative using subs and list comprehension to see the result. We can do the same process for concavity, but use the second derivative diff(f,x,2) instead.