{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
\n",
"
\n",
"
Sage is an open source mathematics computing environment for performing symbolic, algebraic, and numerical computations. Mathematics computing environments are complex, and require a significant amount of time and effort to become proficient at using one. It will take a beginner a while to become an expert in using SAGE, but fortunately one does not need to be a SAGE expert in order to begin using it to solve problems.\n", "\n", "This is precisely the viewpoint we will take in this course. We will not attempt to become Sage experts, we will however us it to solve problems. In particular, problems regarding permutation puzzles.\n", "\n", "A mathematics computing environment is a collection of computer algorithms, and data structures, that are built on top of a programming language. This means one has access to a full programming language, in SageMath's case it is Python, and further access to a mathematical objects library complete with algorithms for performing calculations.\n", "\n", "Rather than say anything more about what SageMath is, let's just see for ourselves what it can do.\n", "\n", "\n", "We can use it like a calculator to add/subtract/multiply/divide numbers.\n", "\n", "Put your cursor in the code block below and either press [shift-enter] or click \"run cell\" (play button) in the menu at the top of the page." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "7" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "2+5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When typing input, [enter] will jump you down to the next line, [shit-enter] will evaluate the code-block.\n", "\n", "A bit of terminology:
\n", "A variable is a name that is associated with the data stored in a memory address. One way to create variables in SageMath is through assignment which consists of placing the variable you would like to create to the left of an equal sign \"=\", and the expression on the right side.\n", "
\n", "\n", "Here we create a variable \"a\", and assign to it the number 5.\n", "
" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "a=5" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "b=7 # create a new variable b and assign 7 to it.\n", "a=3 # reassign to the variable a, the number 3." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c=a+b # assign to the variable c the sum of a and b\n", "c # output the value of c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "