{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# Tutorial : Use SageMath Notebook, navigate in the documentation and use SageMath as a calculator.\n",
"\n",
"This worksheet is an English translation of the French version released for SageMath afternoons in UQAM (http://lacim.uqam.ca/~nadia/) and is broadly inspired by the exercices of Sébastien Labbé's course _Logiciels mathématiques_, that are available online (in French only): http://www.slabbe.org/Enseignements/MATH2010/exercices.pdf\n",
"\n",
"Some other parts come from Franco Saliola's introduction to Sage worksheets or from SageMath documentation (the first thematic tutorial is here : https://doc.sagemath.org/html/en/thematic_tutorials/tutorial-notebook-and-help-long.html)\n",
"\n",
"**It is recommended to first take a tour of the Jupyter notebook.**\n",
"\n",
"To evaluate the content of a line, it suffices to press `Shift + Enter`. Now, try to evaluate a small expression, like the one below. Note that the execution time is always longer for evaluating the first command, because it is starting the kernel."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2 + 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute the number $2^5 \\cdot 3^2 \\cdot 7.$ To answer, create a new cell by clicking on the blue line that appears when hovering over it (n CoCalc), or type `B` in command mode."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute the result of $540931 \\div 83$ under decimal form."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute the integer quotient and the rest of the euclidian division of $540 931$ by $83$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute the sum and the mean of the following values:\n",
" $3121, 71072, 44563, 10986, 43048, 8081, 44681, 23757, 4093, 24805, 30750, 73504.$"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"list1 = [3121, 71072, 44563, 10986, 43048, 8081, 44681, 23757, 4093, 24805, 30750, 73504]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What operation is done first when computing $7 * 2 ** 5 + 3$? Is the value equal to $7 \\cdot 2^{5+3}$?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the expression $3 ** 3 ** 3$. What exponientiation $(**)$ is done first, the first or the second?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let $p(x) = -21 x^5 - 10 x^4 + x^3 + x^2 - 1$. Evaluate $p(x)$ for all values of $x$ in $\\{ 6, 7, 9, 13, 16, 17, 19\\}$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write the expression $\\frac{5}{x+3} + \\frac{3}{x-5} - \\frac{8}{x}$ on a common denominator."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Solve the equation $x^4 - 4 x^3 + 2x^2 - x = 0$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Solve the equation system $x+y = 4, xy = 3$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Find the equation of the line $y = ax +b$ that passes by the points $(8,13)$ and $(5, 37)$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Trace that line."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Trace the curves of the equations $ x + y = 4, xy = 3$ after having isolated the variable $y$. Do the intersection points, if there are some, correspond to those you have obtained above?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Trace the curves of the equations $ 4x^2 + Bxy + 9y^2 = 1$ for different values of $B$ such that $−10 \\leq B \\leq 10$. Deduce the range of the values of $B$ for which the equation describes an ellipse."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is possible to go backwards and modify the content of a cell by clicking on it (or entering the edit mode by typing enter). Without retyping, nor copying, find the equation of the line that passes through $(8, 13)$ and $(18, 26)$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is also possible to modify this text by clicking on it. Or even better, you can insert mathematics in $\\LaTeX$!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ## Obtain some help\n",
"\n",
"There are different ways to access SageMath documentation.\n",
"\n",
" Navigate in the documentation : https://doc.sagemath.org/html/en/tutorial/index.html or, on your computer, http://localhost:8888/kernelspecs/sagemath/doc/index.html\n",
" The Tab-completion\n",
" The contextual help (with the question mark - ?)\n",
" The access to the source code (with the two question marks - ??)\n",
"\n",
"The following examples are made to make you at your ease with those functionalities."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What is the largest prime factor of $600851475143$?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create the permutation $51324$. What is its inverse?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create the matrix\n",
"$$\n",
"M = \\left(\n",
"\\begin{array}{rrrr}\n",
"10 & 4 & 1 & 1 \\\\\n",
"4 & 6 & 5 & 1 \\\\\n",
"1 & 5 & 6 & 4 \\\\\n",
"1 & 1 & 4 & 10\n",
"\\end{array}\n",
"\\right)\n",
"$$\n",
"Is it symmetric? Diagonalizable? Hermitian? (And what means hermitian, by the way? If you don't know or have forgotten, find it in the documentation.) What is its kernel?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Trace the curves of the equations $\\sin(3x +2)$ in blue and $\\cos(x^2+3)$, in red. Indicate the axes."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 8.2",
"language": "",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.14"
}
},
"nbformat": 4,
"nbformat_minor": 1
}