Jupyter notebook assignments/due09-15-16/Introductory Jupyter Notebook.ipynb
Math 231 Writing Assignment 1: Introduction to jupyter and SageMath
The first part of this worksheet contains examples. For Markdown (including Heading cells like the one above), you can double click the cell to see the text that generates the cell, then execute the cell again (by clicking the "run cell" button above) to get back to the output. The second part of this worksheet contains some exercises for you to do.
Examples
In a jupyter notebook, you can enter input and get output. Executing this block will typeset whatever you have typed here.
You can use Markdown mode from the dropdown list in the toolbar above to typeset text. You can also input and typeset mathematical formulas. You enclose them in dollar signs: for example, .
The advantage here is that you can make mathematical formulas fairly complicated, like or like .
Technically, what is in the dollar signs is LaTeX code. Most of the commands begin with a backslash. To see the formulas above better, we can add the displaystyle command: and .
The most common LaTeX mathmatical expressions are summarized here: http://web.ift.uib.no/Teori/KURS/WRK/TeX/symALL.html. You won't need very many of those for this course.
Double click a region to change it from code back to an editable region, then execute the code again when you are finished.
This jupyter notebook has a Kernel running SageMath, which is a computer algebra system. You can do mathematical computations, graphing, and elementary programming. The cells below give some examples of this. Jupyter notebooks can be set up with a variety of kernels, including Python, Octave -- which is kind of like Matlab -- and R (a statistical software package). We will probably only use the Sagemath kernel in this coruse.
The following code prints the values of for . Note: As in a language like Python, range(0,10) gives the whole numbers from 0 to 9. If you want to include 10, you have to use range(0,11).
A jupyter notebook can display graphs. Since was given a value above, we will start by declaring as a variable again.
You can also plot curves implicitly. The following command will plot the curve .
Here is a more complicated example of plotting. The goal is to plot , , and in different colors on the same set of axes for . We will also save this down to a file called our-graph.png. Outputting the result to a .png file is especially helpful if you need to include the graph in a written document or web submission. We will define each of the three plots to be equal to a symbol (a, b, or c), then make d the "sum" of the three plots. We can then perform methods on d (i.e. we can show or save the plot).
SageMath can also do basic computations such as evaluating, differentiating, and integrating expressions. More basic SageMath commands are given in Appendix B of the textbook. (Anything in side a block of code that begins with a "hashtag" symbol is a comment and is ignored when the cell is executed.)
Exercises
. Define a polynomial function that has exactly four -intercepts.
In the Markdown text provided below (the box that says "Answer 1"), write a paragraph in complete sentences explaining what your function is, what its -intercepts are, and how you know. In the paragraph, give your polynomial in the Markdown text in both expanded and factored forms.
In the Code box provided, define your function in SageMath, and plot your function and its first two derivatives on the same set of axes. Be sure that all four -intercepts show on your graph, and use a different color for each curve.
Answer 1.this function can have 4 intercepts at 1,2,3,4
. Suppose you start with 3 cents on Day 1, and the total amount of money that you have doubles each day. (So, on Day 2, you have 6 cents, and on Day 3, you have 12 cents.)
In the Markdown text provided below (the box that says "Answer 2"), write a paragraph in complete sentences explaining how to find a formula for , the number of cents you have on Day . Then, find the day on which you pass $1,000,000.
In the Code box provided, enter code to generate the amount of money you have on Day for . Have SageMath print out pairs of the form .
Answer 2.3*2^(x-1)) it start at 3 at the first day and double evrery other day so it should be 2^(x-1) since it strat with 3
. Come up with an equation in and defining a curve in the -plane that cannot be solved algebraically for or . Plot the curve over a range of values that shows the curve's interesting features. .
Answer 3.