{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# First CoCalc Notebook\n", "\n", "This Week00 Notebook is just to check that you are able to access material in CoCalc and contact a demonstrator.\n", "\n", "Run the cell below by selecting it (click in the cell) and then either pressing the $\\blacktriangleright$ symbol in the menu bar above, or pressing and holding down *Ctrl* then pressing *Enter*." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# \n", "import datetime\n", "now = datetime.datetime.now()\n", "print(\"Date and time \",str(now))\n", "#\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "#\n", "max_iterations = 32\n", "x_min, x_max = -2.5, 1.5\n", "y_min, y_max = -1.5, 1.5\n", "ds = 0.008\n", "nX = int((x_max - x_min)/ds)\n", "nY = int((y_max - y_min)/ds)\n", "X = np.linspace(x_min, x_max, nX)\n", "Y = np.linspace(y_min, y_max, nY)\n", "data = np.zeros((nX, nY), dtype = 'uint8')\n", "for i in range(0, nX):\n", " for j in range(0, nY):\n", " x0, y0 = X[i], Y[j]\n", " x, y = x0, y0\n", " count = 0\n", " while count < max_iterations:\n", " x, y = (x0 + x*x - y*y, y0 + 2*x*y)\n", " if x*x + y*y > 4.0:\n", " break\n", " count += 1\n", " data[i, j] = max_iterations - count\n", " #\n", "fig, ax = plt.subplots(figsize = (20, 15))\n", "plt.tight_layout()\n", "ax.imshow(data.transpose(), interpolation = 'nearest', cmap = 'jet')\n", "plt.axis('off')\n", "plt.show()\n", "#\n", "then = now\n", "now = datetime.datetime.now()\n", "print(\" \")\n", "print(\"Date and time\",str(now))\n", "print(\"Time since last check is\",str(now - then))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Show the result to one of the online demonstrators." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.7.9" } }, "nbformat": 4, "nbformat_minor": 4 }