\n",
"\n",
"\n",
"## Instructors: \n",
"\n",
"* **Evans Ocansey**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Homework Assignment (due Saturday 16th November 2024, 13:00 GMT+2) \n",
"\n",
"\n",
"Instructions for homework assignments: \n",
"- Make sure to rename this notebook by replacing the word `username` with your AIMS username. For example, if my name is `Evans`, then I will rename this notebook to be `ems_2024_25_assignment_02_evans`.\n",
"- You must write, type, use Jupyter notebook, or use $\\LaTeX$ to submit homework. **ALL CODE MUST BE EXPLAINED**. That means you should have at least one English sentence to explain each line of code that you write. This may be in a form of a comments or in a paragraph after each computation in your upyter notebook.\n",
"- Similarly, do not simply write your explorations as lists of numbers, but write explanations of what you tried, and what didn’t work.\n",
"- Do **NOT** use internet resources, or GPT-like models for the exploration; for help with _SageMath_ or _Python_ you may search the internet, of course. You are also welcome to ask me or any of the tutors.\n",
"- The starred (*) exercises are more important; you should be working on them early and often. To pass the course you should try to do all the starred exercises.\n",
"\n",
"The outline of this notebook is as follows:\n",
"\n",
"## Table of Contents: \n",
"* [Exercise 01](#exercise-01)\n",
"* [Exercise 02](#exercise-02)\n",
"* [Exercise 03](#exercise-03)\n",
"* [Exercise 04](#exercise-04)\n",
"* [Exercise 05](#exercise-05)\n",
"* [Exercise 06](#exercise-06)\n",
"* [Exercise 07](#exercise-07)\n",
"* [Exercise 08](#exercise-08)\n",
"* [Exercise 09](#exercise-09)\n",
"* [Exercise 10](#exercise-10)\n",
"* [Exercise 11](#exercise-11)\n",
"* [Exercise 12](#exercise-11)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 01 \n",
"\n",
"(*) Pick one of the following topics or any topic of your interest. Write a small tutorial (in English) about this topic to introduce a beginner to doing this topic with Sage. You should use your own words and it should have at least three paragraphs, along with at least four longer Sage examples. \n",
"- Multivariable Calculus\n",
"- Graph Theory\n",
"- Number Theory\n",
"- Differential Equations\n",
"- Linear Algebra\n",
"- Statistics\n",
"- Abstract Algebra\n",
"- Operation Research\n",
"- Optimization\n",
"- Communications\n",
"- Financial Mathematics"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 02 \n",
"\n",
"(*) Make a complicated plot, with the following criteria. \n",
"It should have at least three separate plots you combine, one of which is not just plotting a function (it could be data, implicit, a shape, etc.).\n",
"\n",
"You should use at least TEN different optional graphics keywords properly (and meaningfully).\n",
"\n",
"As usual, explain what you did!\n",
"\n",
"For a bonus, you can animate it (the animation must be meaningful, though). See the Sage function animate. You can also read the help file [here](https://doc.sagemath.org/html/en/reference/plotting/sage/plot/animate.html).\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 03 \n",
"\n",
"(*) Write up your code and explorations of $n=a^2+b^2$. I want to know all the patterns you found. Do you have any ideas about formulas? You can discuss prime numbers, remainders/modulo, the number of ways to write $n$ in this form, geometric insights, or anything else. Show your creativity! Also explain what you did; do not just give results."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 04 \n",
"\n",
"(*) Investigate one other (binary) quadratic form that you have picked. Explore it in the same way as the previous one. Tell me about all the patterns you found, just like in the previous question. Are there any interesting equivalent quadratic forms you found?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 05 \n",
"\n",
"(*) By looking at the values of $n$ possible (by hand or by using Sage), observe that the quadratic forms $x^2+2\\,y^2$ and $x^2+2\\,x\\,y +3\\,y^2$ seem to represent the same values; record your experimentation. Check that these forms have the same discriminant, and then find an algebraic transformation (or matrix) that will convert one into the other."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 06 \n",
"\n",
"The form $2\\,x^2+3\\,y^2$ has discriminant $-24$. Find another binary quadratic form of the form $a\\,x^2+b\\,y^2$ which has the same discriminant, but which can represent a number that $2\\,x^2+3\\,y^2$ cannot, and hence is not equivalent. Explain what you did to find this form."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 07 \n",
"\n",
"In the proof that for $n$ odd: \n",
"\n",
"$$\n",
"3\\,Q(n) = Q(2n)\n",
"$$ \n",
"\n",
"in Wednesday's lecture, fill in the details for two of the steps so that you could explain it to someone else."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 08 \n",
"\n",
"Show that $23$ is not writable as a sum of only eight perfect positive cube numbers. Can you write it as a sum of fewer than eight perfect cubes, negative or positive? What is the other number which requires nine cubes? Be sure to show your code or reasoning!"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 09 \n",
"\n",
"Prove that $a\\,(a+1)\\,(2a+1)$ is always divisible by $6$. \n",
"\n",
"**Hint**: Use cases for the possibilities of what $a$ can be modulo $6$."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 10 \n",
"\n",
"Implement the prime counting function:\n",
"\n",
"$$\n",
" \\pi(n)=-1+\\sum_{j=3}^{n}\\left((j-2)!-j\\left\\lfloor\\frac{(j-2)!}{j}\\right\\rfloor\\right)\n",
"$$\n",
"\n",
"in Sage and check that it works for small values. (Don't try big ones because of the factorials unless you want to crash your computer!) As always, comment and explain your code."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The last two exercises:\n",
"\n",
"- [Exercise 11](#exercise-11)\n",
"- [Exercise 12](#exercise-12)\n",
"\n",
"are optional. They are designed to encourage and challenge students who wish to further develop and strengthen their programming skills."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 11 \n",
"\n",
"\n",
"1. Draw a [vertex labelled graph](http://mathworld.wolfram.com/LabeledGraph.html). (You may want to draw something simple.)\n",
"2. Which _Python_ datatype would be best to encode any [vertex labelled graph](http://mathworld.wolfram.com/LabeledGraph.html)?\n",
"3. Use the _SageMath_ documentation on `Graph` to construct the vertex-labelled graph that you drew in part 1.\n",
"4. Apply as many methods as you can to the `Graph` object that you created in part 3.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 12 \n",
"\n",
"Random walk on the graph you defined in [Exercise 11](#exercise-11)\n",
"\n",
"Suppose there is a robot standing on one of the vertices of the graph that you defined in [Exercise 11](#exercise-11). This position can be chosen randomly. Write a Python function named `random_walk_on_graph` that takes a positive integer as input — representing the number of walks the robot makes on the vertices of your graph — and returns a table that records the number of times the robot visited each vertex in your graph. What is the position of the robot at the $100$-th step? What can you observe about the tabulated data? \n",
"\n",
"**Hint**: Read the help documentation on the _SageMath_ functions `choice` and `table`. You may need them in your code. What did you observe from the tabulated data?\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 10.4",
"language": "sage",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}