for val in [0, 10, 30, 50, 70, 90, 110]] [revenue.subs({Q:val})
Lab 3
Goals for today
Just like our first two sessions, the idea of these labs is for you to learn enough so that you can use SymPy to help you out when checking answers if you work on examples and exercises in our book.
Our goals for today are:
- Wrap up Lab 2. Reload the webpage to get an updated version.
- You will be creating your first Google Colab notebook. More details can be found below.
- As always, each student works through the exercise and picks up the skills needed to implement what you saw in the lecture in the computer.
- If you need to look up new commands, go to the documentation.
- There is no self-evaluation form this time, but you have to submit the notebook (and whatever its contents are) to Animospace. You are graded for completeness rather than correctness of your notebook.
Understanding why optimization works
Chapter 8 relies a lot on the first two derivatives of a differentiable function. You may have to refer to the idea of second-order Taylor polynomials to gain some insight as to why we rely on the first two derivatives.
Consider the example \[c(t)=\frac{t}{t^2+4}.\] Recall that \(t=2\) maximizes \(c(t)\). If you follow the discussion in the link for second-order Taylor polynomials, you can construct a second-order Taylor polynomial around \(t=2\). It is given by \[P_2(t)=c(2)+c^\prime(2)(t-2)+\frac{1}{2}c^{\prime\prime}(2)(t-2)^2.\]
Plot \(c(t)\) and \(P_2(t)\) on intervals centered around \(t=2\). Try making adjustments to the visualization for both axes by consulting the documentation for plotting here.
Creating your first notebook
Go to Google Colab and make sure you are logged in to your DLSU Gmail account.
- Create a new notebook.
- Save this notebook into your Google drive. In the Colab menu, you will find “Locate Notebook”. This will guide you to where your notebook is located.
After finishing the previous exercise, you now have your very first notebook. Now, let us put something useful in your notebook.
- Using your notebook as the starting point, reproduce the findings found in Table 1 of Section 8.5 Example 2. Start with a code cell. Because we are no longer in the Live SymPy Shell, you need to do some setup in order to get to the point where you will be able to evaluate
After that, introduce cost
and profit
so that you can complete the table.
- Add code to find stationary points and use the Extreme Value Theorem (Why?) to find the optimal \(Q\) which will maximize profits.
A notebook is not complete without documentation of findings.
Let us put some text and formulas in your notebook. Add a text cell. Write an analysis of your findings.
Now do an exercise on your own for practice.
Finally, try to answer Section 8.6 Exercise 3b and 3c. Write out code that enables you to find the answers and write up your findings.