From 7eccd3ef4c536318915f3e1c029103b349e81268 Mon Sep 17 00:00:00 2001 From: "R. Bernstein" Date: Tue, 26 May 2026 11:56:55 -0400 Subject: [PATCH 1/3] Update GitHub project link in index.html --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 6d9a0b7..1ec53bc 100644 --- a/index.html +++ b/index.html @@ -343,7 +343,7 @@

About this page

Once the above is run, cell input is interpreted as Mathics3 code, and neither magic commands %pip nor %load_ext are interpreted.

Press SHIFT+ENTER to run the code or use the Run button in the toolbar.

- It can take up to 30 seconds before the shell code and libraries load completely and become available for using interactively. When the [*] + It can take up to 30 seconds before the shell code and libraries load completely and become available for interactive use. When the [*] on the first line to turns to [1], the extension has been loaded.

@@ -369,7 +369,7 @@

Example sessions

From ec6181f36bea982a49c137ba2628530e026bc7ba Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 30 May 2026 13:19:27 -0400 Subject: [PATCH 2/3] Update examples --- Mathics3-notebook-frontends | 2 +- content/Mathics3-Extension-Gallery.ipynb | 3790 +++++++++++++++++ content/Mathics3-Extension-Introduction.ipynb | 1041 +++++ index.html | 6 +- 4 files changed, 4835 insertions(+), 4 deletions(-) create mode 100644 content/Mathics3-Extension-Gallery.ipynb create mode 100644 content/Mathics3-Extension-Introduction.ipynb diff --git a/Mathics3-notebook-frontends b/Mathics3-notebook-frontends index b34e437..639c09d 160000 --- a/Mathics3-notebook-frontends +++ b/Mathics3-notebook-frontends @@ -1 +1 @@ -Subproject commit b34e43789ef2063f4fb1c1cd9319118bfe1c9c64 +Subproject commit 639c09d28387f3a7ea82b0b2abb78be42e37f588 diff --git a/content/Mathics3-Extension-Gallery.ipynb b/content/Mathics3-Extension-Gallery.ipynb new file mode 100644 index 0000000..789b1cc --- /dev/null +++ b/content/Mathics3-Extension-Gallery.ipynb @@ -0,0 +1,3790 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "14ab24aa-0768-4857-acf2-a05e304dd870", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[33mWARNING: Cache entry deserialization failed, entry ignored\u001b[0m\u001b[33m\n", + "\u001b[0mUsing pip 26.1.1 from /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages/pip (python 3.14)\n", + "Requirement already satisfied: Mathics3 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (10.0.2.dev0)\n", + "Requirement already satisfied: Mathics3-notebook-frontends in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (1.0.0)\n", + "Requirement already satisfied: Mathics3-Module-networkx in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (10.0.0)\n", + "Requirement already satisfied: ipywidgets in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (8.1.8)\n", + "Requirement already satisfied: lxml in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (6.0.2)\n", + "Requirement already satisfied: pyocr in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (0.8.5)\n", + "Requirement already satisfied: scikit-image in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (0.26.0)\n", + "Requirement already satisfied: unidecode in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (1.4.0)\n", + "Requirement already satisfied: wordcloud in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (1.9.6)\n", + "Requirement already satisfied: Mathics3_Scanner>=10.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (10.0.1)\n", + "Requirement already satisfied: mpmath>=1.2.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (1.3.0)\n", + "Requirement already satisfied: numpy in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (2.4.4)\n", + "Requirement already satisfied: palettable in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (3.3.3)\n", + "Requirement already satisfied: pillow>=9.2 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (12.1.1)\n", + "Requirement already satisfied: pint>=0.24 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (0.25.3)\n", + "Requirement already satisfied: python-dateutil in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (2.9.0.post0)\n", + "Requirement already satisfied: python-magic in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (0.4.27)\n", + "Requirement already satisfied: Pympler in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (1.1)\n", + "Requirement already satisfied: requests in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (2.33.0)\n", + "Requirement already satisfied: scipy in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (1.17.1)\n", + "Requirement already satisfied: setuptools in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (82.0.1)\n", + "Requirement already satisfied: Timed-Threads in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (2.0.0)\n", + "Requirement already satisfied: sympy>=1.13 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3) (1.13.3)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-notebook-frontends) (2.6.3)\n", + "Requirement already satisfied: chardet<6.0.0,>=3.0.2 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-notebook-frontends) (5.2.0)\n", + "Requirement already satisfied: charset-normalizer<4.0.0,>=2.0.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-notebook-frontends) (3.4.6)\n", + "Requirement already satisfied: Mathics3-Module-Base in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-Module-networkx) (9.0.1.dev0)\n", + "Requirement already satisfied: networkx>=3.0.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-Module-networkx) (3.6.1)\n", + "Requirement already satisfied: pydot in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-Module-networkx) (4.0.1)\n", + "Requirement already satisfied: matplotlib in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3-Module-networkx) (3.10.8)\n", + "Requirement already satisfied: comm>=0.1.3 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipywidgets) (0.2.3)\n", + "Requirement already satisfied: ipython>=6.1.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipywidgets) (9.12.0)\n", + "Requirement already satisfied: traitlets>=4.3.1 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipywidgets) (5.14.3)\n", + "Requirement already satisfied: widgetsnbextension~=4.0.14 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipywidgets) (4.0.15)\n", + "Requirement already satisfied: jupyterlab_widgets~=3.0.15 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipywidgets) (3.0.16)\n", + "Requirement already satisfied: imageio!=2.35.0,>=2.33 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from scikit-image) (2.37.3)\n", + "Requirement already satisfied: tifffile>=2022.8.12 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from scikit-image) (2026.3.3)\n", + "Requirement already satisfied: packaging>=21 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from scikit-image) (26.0)\n", + "Requirement already satisfied: lazy-loader>=0.4 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from scikit-image) (0.5)\n", + "Requirement already satisfied: decorator>=5.1.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (5.2.1)\n", + "Requirement already satisfied: ipython-pygments-lexers>=1.0.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (1.1.1)\n", + "Requirement already satisfied: jedi>=0.18.2 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (0.19.2)\n", + "Requirement already satisfied: matplotlib-inline>=0.1.6 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (0.2.1)\n", + "Requirement already satisfied: pexpect>4.6 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (4.9.0)\n", + "Requirement already satisfied: prompt_toolkit<3.1.0,>=3.0.41 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (3.0.52)\n", + "Requirement already satisfied: pygments>=2.14.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (2.20.0)\n", + "Requirement already satisfied: stack_data>=0.6.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from ipython>=6.1.0->ipywidgets) (0.6.3)\n", + "Requirement already satisfied: wcwidth in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from prompt_toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets) (0.6.0)\n", + "Requirement already satisfied: parso<0.9.0,>=0.8.4 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from jedi>=0.18.2->ipython>=6.1.0->ipywidgets) (0.8.6)\n", + "Requirement already satisfied: PyYAML in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3_Scanner>=10.0->Mathics3) (6.0.3)\n", + "Requirement already satisfied: click in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from Mathics3_Scanner>=10.0->Mathics3) (8.3.1)\n", + "Requirement already satisfied: ptyprocess>=0.5 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from pexpect>4.6->ipython>=6.1.0->ipywidgets) (0.7.0)\n", + "Requirement already satisfied: flexcache>=0.3 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from pint>=0.24->Mathics3) (0.3)\n", + "Requirement already satisfied: flexparser>=0.4 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from pint>=0.24->Mathics3) (0.4)\n", + "Requirement already satisfied: platformdirs>=2.1.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from pint>=0.24->Mathics3) (4.9.4)\n", + "Requirement already satisfied: typing-extensions>=4.0.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from pint>=0.24->Mathics3) (4.15.0)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from requests->Mathics3) (3.11)\n", + "Requirement already satisfied: certifi>=2023.5.7 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from requests->Mathics3) (2026.2.25)\n", + "Requirement already satisfied: executing>=1.2.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from stack_data>=0.6.0->ipython>=6.1.0->ipywidgets) (2.2.1)\n", + "Requirement already satisfied: asttokens>=2.1.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from stack_data>=0.6.0->ipython>=6.1.0->ipywidgets) (3.0.1)\n", + "Requirement already satisfied: pure-eval in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from stack_data>=0.6.0->ipython>=6.1.0->ipywidgets) (0.2.3)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from matplotlib->Mathics3-Module-networkx) (1.3.3)\n", + "Requirement already satisfied: cycler>=0.10 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from matplotlib->Mathics3-Module-networkx) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from matplotlib->Mathics3-Module-networkx) (4.62.1)\n", + "Requirement already satisfied: kiwisolver>=1.3.1 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from matplotlib->Mathics3-Module-networkx) (1.5.0)\n", + "Requirement already satisfied: pyparsing>=3 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from matplotlib->Mathics3-Module-networkx) (3.3.2)\n", + "Requirement already satisfied: six>=1.5 in /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages (from python-dateutil->Mathics3) (1.17.0)\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:root:``import_and_load_builtins`` should be called just once...\n" + ] + }, + { + "data": { + "application/javascript": [ + "\n", + " var script = document.createElement('script');\n", + " script.type = 'text/javascript';\n", + " script.src = 'https://cdn.jsdelivr.net/npm/@mathicsorg/mathics-threejs-backend';\n", + " document.head.appendChild(script);\n", + " console.log('Loading mathics-threejs-backend');\n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%pip install -v Mathics3 Mathics3-notebook-frontends Mathics3-Module-networkx ipywidgets lxml pyocr scikit-image unidecode wordcloud\n", + "%load_ext mathics3_kernel.frontend.jupyter" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e65ee66f-546e-4bd3-ba17-31ed55144b1e", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "The first line of a Mathics3 extension has some sort of `%load_ext` in it. \n", + "It can be preceded by a `%pip install` like we have in the cell above.\n", + "\n", + "## Some algebraic functions.\n", + "\n", + "First, we'll start with some numeric calculations.\n", + "\n", + "Euler's famous equation:\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "The first line of a Mathics3 extension has some sort of `%load_ext` in it. \n", + "It can be preceded by a `%pip install` like we have in the cell above.\n", + "\n", + "## Some algebraic functions.\n", + "\n", + "First, we'll start with some numeric calculations.\n", + "\n", + "Euler's famous equation:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "4952eb49-73a4-4fa5-981c-567f35ef223d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle -1$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "E ^ (Pi I)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "e8133171-b9f2-4545-b561-55a478bd61bc", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "`E` is a Mathics3 symbolic constant whose value is precisely evaluated in expressions. \n", + "\n", + "However, we can get its numeric approximation: \n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "`E` is a Mathics3 symbolic constant whose value is precisely evaluated in expressions. \n", + "\n", + "However, we can get its numeric approximation: " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "15de0eb5-0ec3-4f24-a0a3-838fe3e8392f", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 2.718281828459045$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "N[E]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "03f8c925-5dd1-474c-acb2-ae68909dfbc6", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 2.718281828459045235360287471353$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* You can also explicitly specify the number of digits of accuracy.\n", + "Mathics3 supports arbitrarily large precision. *)\n", + "N[E, 30]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "ce351c5b-979d-4b9c-83fc-e41171f07438", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 265252859812191058636308480000000$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* As well as arbitrarily large integers: *)\n", + "30! \n", + "(* All Factorials over 5! have zeros at the end. *)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "c3d1c89a-c2cb-44a5-86aa-68974040c937", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Functions for working with Polyomials\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Functions for working with Polyomials" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "32eb8fac-6a01-410e-afd6-4d5e904fdaff", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle -\\frac{1}{2 y (x+y)}+\\frac{1}{2 y (x-y)}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Apart[1 / (x^2 - y^2), x]" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "39e784cd-fd7e-404d-929d-3cf095aabf78", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 1+2 x+x^2$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Expand[(x+1)^2]" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "29cb68a8-3662-443f-9535-067b54e3f3f1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle (-6+x) (1+x)$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Factor[x^2 -5x -6]" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "06d4cf07-c389-4818-9339-37118517a394", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{1}{x}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Cancel[x / x^2]" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "7f17d1fa-fb4c-4f9e-874f-6d91ce876b0d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Calculus\n", + "\n", + "First-order derivative of a polynomial:\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Calculus\n", + "\n", + "First-order derivative of a polynomial:" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "a9674af0-62ea-4322-9a44-ef1e6cd8dcdf", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 6 x+3 x^2$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "D[x^3 + 3 x^2, x]" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4a1eded6-e107-4127-9614-ea59bf452197", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 6+6 x$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Second-order derivative: *)\n", + "D[x^3 + 3 x^2, {x, 2}]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "e3d81f5e-3798-4f7e-a715-5a0c7588fb74", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle f'\\left[x\\right]$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "D[f[x], x]" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "f939c528-354c-4e53-9197-31f5a8e3d478", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 1-y+\\frac{y^2}{2}+O[y]^3+\\left(1-y+\\frac{y^2}{2}+O[y]^3\\right) x+\\left(\\frac{1}{2}-\\frac{y}{2}+\\frac{y^2}{4}+O[y]^3\\right) x^2+O[x]^3$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Series[Exp[x-y], {x, 0, 2}, {y, 0, 2}]" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "564121e9-f4e4-4229-b50b-b1b152eb43dc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\{\\{x \\to 1\\}\\}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Solve[x^3 == 1, x, Reals]" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "f0df3677-a8d1-40c5-b70c-88489ef1db33", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left\\{\\frac{-4 \\left(-5+x^2\\right)}{{\\left(5+3 x+x^2\\right)}^2}, \\frac{8 \\left(-15-15 x+x^3\\right)}{{\\left(5+3 x+x^2\\right)}^3}, \\frac{-24 \\left(-20-60 x-30 x^2+x^4\\right)}{{\\left(5+3 x+x^2\\right)}^4}\\right\\}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Show a list of the first 3 Derivatives of a function. Show these in combined form: *)\n", + "f[x_] := 4 x / (x ^ 2 + 3 x + 5);\n", + "{f'[x], f''[x], f'''[x]} // Together" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "1b71000d-3092-43dc-85c6-d6af938198d9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Graphics\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Graphics" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "06e5a85a-f6fe-4498-8253-cc99aed24185", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Graphics[Table[{Hue[h, s], Disk[{12h, 8s}]}, {h, 0, 1, 1/6}, {s, 0, 1, 1/4}]]" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "a3113b09-6279-4e0d-bdc1-8828800fba6d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Another Table of Graphics: *)\n", + "Graphics[Table[\n", + " {EdgeForm[{GrayLevel[0, 0.5]}], \n", + " Hue[(-11+q+10r)/72, 1, 1, 0.6], \n", + " Disk[(8-r){Cos[2Pi q/12], Sin[2Pi q/12]}, (8-r)/3]}, {r, 6}, {q, 12}]\n", + " ]" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "eca66111-36c6-47b6-8395-303530e48977", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "0pt\n", + "\n", + "\n", + "1pt\n", + "\n", + "\n", + "2pt\n", + "\n", + "\n", + "3pt\n", + "\n", + "\n", + "4pt\n", + "\n", + "\n", + "5pt\n", + "\n", + "\n", + "6pt\n", + "\n", + "\n", + "7pt\n", + "\n", + "\n", + "8pt\n", + "\n", + "\n", + "9pt\n", + "\n", + "\n", + "10pt\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* A table of Lines of various thicknesses. *)\n", + "Graphics[Table[{AbsoluteThickness[t], Line[{{20 t, 10}, {20 t, 80}}], Text[ToString[t]<>\"pt\", {20 t, 0}]}, {t, 0, 10}]]" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "49ef2861-63d2-41d8-a837-aaded5ee8834", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* A way to randomly draw the Sierpinski Triangle. *)\n", + "vertices = {{0,0}, {1,0}, {.5, .5 Sqrt[3]}};\n", + "points = NestList[.5(vertices[[ RandomInteger[{1,3}] ]] + #)&, {0.,0.}, 1000];\n", + "Graphics[Point[points], ImageSize->Large]" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "9b1fbb80-3d44-41e7-a423-535385ca6836", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle {{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}_{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}^{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}}_{{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}_{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}^{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}}^{{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}_{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}^{{{0_0^0}_{0_0^0}^{0_0^0}}_{{0_0^0}_{0_0^0}^{0_0^0}}^{{0_0^0}_{0_0^0}^{0_0^0}}}}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Another way to draw the same Sierpinski Triangle using in character form using subscripts and superscripts *)\n", + "Nest[Subsuperscript[#,#,#]&,0,5]" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "88df853c-2b60-45d1-ba71-c880e595a887", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Plotting\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Plotting" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "679a53d5-b421-4389-885d-508b80bfe636", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "-1.0\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n", + "\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* We can plot several functions in one graph: *)\n", + "Plot[{Sin[x], Cos[x], x ^ 2}, {x, -1, 1}]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3f3fda30-0265-45c9-9c73-b3800151aba5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "516268d6-7cad-42ac-a89f-1cca6bc1c942", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "10\n", + "20\n", + "30\n", + "40\n", + "50\n", + "\n", + "\n", + "\n", + "\n", + "-1.0\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* ListLinePlot allows a Filling option. *)\n", + "ListLinePlot[Table[Sin[x], {x, -5, 5, 0.2}], Filling->Axis]" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "058fef59-60fa-4459-beaf-91e9c7390ba5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "-1.0\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n", + "\n", + "-1.0\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Another kind of plot is a Parameteric Plot *)\n", + "ParametricPlot[{Sin[u], Cos[3 u]}, {u, 0, 2 Pi}]" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "ca41269b-072c-43a8-9899-a397718bf09c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "-1.0\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n", + "\n", + "-1.0\n", + "-0.5\n", + "0.5\n", + "1.0\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* And we also have PolarPlots *)\n", + "Clear[t]; PolarPlot[{1, 1 + Sin[20 t] / 5}, {t, 0, 2 Pi}]" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "45ee8c44-e737-4e22-bb1e-c467f5abe26e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Functions\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Functions" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "778879d7-df9c-4a4e-8a2c-2eb25bea37ea", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "5\n", + "10\n", + "15\n", + "\n", + "\n", + "\n", + "\n", + "10\n", + "20\n", + "30\n", + "40\n", + "50\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* An example involving function evaluation. The Collatz function appears to converge to 1, but there is no proof of this. *)\n", + "collatz[1] := 1;\n", + "collatz[x_ ? EvenQ] := x / 2;\n", + "collatz[x_] := 3 x + 1;\n", + "list = FixedPointList[collatz, 14];\n", + "ListLinePlot[list]" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "4109a478-9313-4475-a336-fb2ecec9c1ef", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lindenmayer[i_, b_, h_, j_, r_, n_] := \n", + " (a = h; p = j; s = k = {}; t = Flatten;\n", + " (Switch[#,\n", + " 6, s = {a, p, s},\n", + " 8, {a, p, s} = s,\n", + " _C, k = {k, Line@{p, p += {Cos@a, Sin@a}}}];\n", + " If[# < 9, a += I^# b ]) & /@ t@Nest[# /. r &, i, n];\n", + " Graphics@t@k);\n", + "lindenmayer[{C[1], X}, Pi/2, 0, {0, 0}, {X -> {X, 4, Y, C[1]}, Y -> {C[1], X, 2, Y}}, 7]" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "8e3ff40b-2083-4f51-8e39-8e1136481fb1", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Running Python \n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Running Python " + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "124befd0-8a2e-4137-85b4-b501e57e61fc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%python 2+4 # You can also write as: %py 2 + 4" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "a1b98cd6-02b0-44c0-b7b8-b8fd1e4570d9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\{1, 3, 6, 10, 15\\}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Table[(n (n+1))/2, {n, 5}] (* The first 5 triangle numbers *)" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "379f0f60-6804-4dc2-9986-726fbff17e87", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + ", , , , )>" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%py session.last_result" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "a1725287-edc1-41f7-b886-638e1438daff", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Name: columnize\n", + "Version: 0.3.11\n", + "Summary: Format a simple (i.e. not nested) list into aligned columns.\n", + "Home-page: https://github.com/rocky/pycolumnize\n", + "Author: Rocky Bernstein\n", + "Author-email: rocky@gnu.org\n", + "License: MIT\n", + "Location: /home/rocky/.pyenv/versions/3.14.3/lib/python3.14/site-packages\n", + "Requires: \n", + "Required-by: Mathics3_script, mathicsscript, trepan3k\n" + ] + } + ], + "source": [ + "%pip show columnize" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "59e09311-5d70-46ea-82dc-a86a6ef28868", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\u001b[1;34mUsage:\u001b[0m \n", + " /home/rocky/.pyenv/versions/3.14.3/bin/python3.14 -m pip [options]\n", + "\n", + "\u001b[1;34mCommands:\u001b[0m\n", + " \u001b[36minstall \u001b[0m Install packages.\n", + " \u001b[36mlock \u001b[0m Generate a lock file.\n", + " \u001b[36mdownload \u001b[0m Download packages.\n", + " \u001b[36muninstall \u001b[0m Uninstall packages.\n", + " \u001b[36mfreeze \u001b[0m Output installed packages in requirements format.\n", + " \u001b[36minspect \u001b[0m Inspect the python environment.\n", + " \u001b[36mlist \u001b[0m List installed packages.\n", + " \u001b[36mshow \u001b[0m Show information about installed packages.\n", + " \u001b[36mcheck \u001b[0m Verify installed packages have compatible dependencies.\n", + " \u001b[36mconfig \u001b[0m Manage local and global configuration.\n", + " \u001b[36msearch \u001b[0m Search PyPI for packages.\n", + " \u001b[36mcache \u001b[0m Inspect and manage pip's wheel cache.\n", + " \u001b[36mindex \u001b[0m Inspect information available from package indexes.\n", + " \u001b[36mwheel \u001b[0m Build wheels from your requirements.\n", + " \u001b[36mhash \u001b[0m Compute hashes of package archives.\n", + " \u001b[36mcompletion \u001b[0m A helper command used for command completion.\n", + " \u001b[36mdebug \u001b[0m Show information useful for debugging.\n", + " \u001b[36mhelp \u001b[0m Show help for commands.\n", + "\n", + "\u001b[1;34mGeneral Options:\u001b[0m\n", + " \u001b[32m-h\u001b[0m, \u001b[36m--help\u001b[0m Show help.\n", + " \u001b[36m--debug\u001b[0m Let unhandled exceptions propagate outside the main subroutine, instead of logging them to stderr.\n", + " \u001b[36m--isolated\u001b[0m Run pip in an isolated mode, ignoring environment variables and user configuration.\n", + " \u001b[36m--require-virtualenv\u001b[0m Allow pip to only run in a virtual environment; exit with an error otherwise.\n", + " \u001b[36m--python\u001b[0m \u001b[33m\u001b[0m Run pip with the specified Python interpreter.\n", + " \u001b[32m-v\u001b[0m, \u001b[36m--verbose\u001b[0m Give more output. Option is additive, and can be used up to 3 times.\n", + " \u001b[32m-V\u001b[0m, \u001b[36m--version\u001b[0m Show version and exit.\n", + " \u001b[32m-q\u001b[0m, \u001b[36m--quiet\u001b[0m Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).\n", + " \u001b[36m--log\u001b[0m \u001b[33m\u001b[0m Path to a verbose appending log.\n", + " \u001b[36m--no-input\u001b[0m Disable prompting for input.\n", + " \u001b[36m--keyring-provider\u001b[0m \u001b[33m\u001b[0m\n", + " Enable the credential lookup via the keyring library if user input is allowed. Specify which mechanism to use [auto, disabled, import, subprocess]. (default: auto)\n", + " \u001b[36m--proxy\u001b[0m \u001b[33m\u001b[0m Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.\n", + " \u001b[36m--retries\u001b[0m \u001b[33m\u001b[0m Maximum attempts to establish a new HTTP connection. (default: 5)\n", + " \u001b[36m--timeout\u001b[0m \u001b[33m\u001b[0m Set the socket timeout (default 15 seconds).\n", + " \u001b[36m--exists-action\u001b[0m \u001b[33m\u001b[0m Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.\n", + " \u001b[36m--trusted-host\u001b[0m \u001b[33m\u001b[0m Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.\n", + " \u001b[36m--cert\u001b[0m \u001b[33m\u001b[0m Path to PEM-encoded CA certificate bundle. If provided, overrides the default. See 'SSL Certificate Verification' in pip documentation for more information.\n", + " \u001b[36m--client-cert\u001b[0m \u001b[33m\u001b[0m Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.\n", + " \u001b[36m--cache-dir\u001b[0m \u001b[33m\u001b[0m Store the cache data in .\n", + " \u001b[36m--no-cache-dir\u001b[0m Disable the cache.\n", + " \u001b[36m--disable-pip-version-check\u001b[0m\n", + " Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with\u001b[36m --no-index\u001b[0m.\n", + " \u001b[36m--no-color\u001b[0m Suppress colored output.\n", + " \u001b[36m--use-feature\u001b[0m \u001b[33m\u001b[0m Enable new functionality, that may be backward incompatible.\n", + " \u001b[36m--use-deprecated\u001b[0m \u001b[33m\u001b[0m Enable deprecated functionality, that will be removed in the future.\n", + " \u001b[36m--resume-retries\u001b[0m \u001b[33m\u001b[0m\n", + " Maximum attempts to resume or restart an incomplete download. (default: 5)\n" + ] + } + ], + "source": [ + "%pip" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "07c42103-2e03-4a6f-a447-f75a79169fe9", + "metadata": {}, + "outputs": [], + "source": [ + "%py \n", + "def fib(n: int) -> int:\n", + " if 0 <= n <= 1:\n", + " return 1\n", + " if n < 0: return -fib(-n)\n", + " return n * fib(n - 1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "1c3857c6-07a5-4cec-87c8-3d3f08d27d95", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%py fib(3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5e54cbf3-f46c-4c06-83f3-62caf3321f91", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.14.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/content/Mathics3-Extension-Introduction.ipynb b/content/Mathics3-Extension-Introduction.ipynb new file mode 100644 index 0000000..145f8a9 --- /dev/null +++ b/content/Mathics3-Extension-Introduction.ipynb @@ -0,0 +1,1041 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "06eed4bd-429a-4463-b63e-8032eee05cdb", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:root:``import_and_load_builtins`` should be called just once...\n" + ] + }, + { + "data": { + "application/javascript": [ + "\n", + " var script = document.createElement('script');\n", + " script.type = 'text/javascript';\n", + " script.src = 'https://cdn.jsdelivr.net/npm/@mathicsorg/mathics-threejs-backend';\n", + " document.head.appendChild(script);\n", + " console.log('Loading mathics-threejs-backend');\n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%load_ext mathics3_kernel.frontend.jupyter" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "bb323731-273a-4eb8-8275-3765e37a8dc5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "# Mathics3 Jupyter Kernel Introduction\n", + "\n", + "Here we describe some features of the Mathics3 Jupyter Kernel.\n", + "\n", + "First, we will start with markdown text.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "# Mathics3 Jupyter Kernel Introduction\n", + "\n", + "Here we describe some features of the Mathics3 Jupyter Kernel.\n", + "\n", + "First, we will start with markdown text." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "e70208ad-7694-4b99-976a-3090be64e7c4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "## Markdown Markup in cells: `%m3md`\n", + "\n", + "A cell is tagged as markup text by starting the cell with `%m3md` as this and the last cell do.\n", + "\n", + "Cells can be marked using the typical markup tags. For example, a first-level heading starts with `#` at the beginning of a line. \n", + "See the text of the previous cell for an example of this.\n", + "\n", + "A second-level heading is indicated by starting a line with `##`, as this cell does.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "## Markdown Markup in cells: `%m3md`\n", + "\n", + "A cell is tagged as markup text by starting the cell with `%m3md` as this and the last cell do.\n", + "\n", + "Cells can be marked using the typical markup tags. For example, a first-level heading starts with `#` at the beginning of a line. \n", + "See the text of the previous cell for an example of this.\n", + "\n", + "A second-level heading is indicated by starting a line with `##`, as this cell does.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "d9f39cdd-0c1a-48eb-b371-1f9ea73eaed6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "## Markdown Markup in cells: `%m3md`\n", + "\n", + "A cell is tagged as markup text by starting the cell with `%m3md` as this and the last cell do.\n", + "\n", + "Cells can be marked using the typical markup tags. For example, a first-level heading starts with `#` at the beginning of a line. \n", + "See the text of the previous cell for an example of this.\n", + "\n", + "A second-level heading is indicated by starting a line with `##`, as this cell does.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "## Markdown Markup in cells: `%m3md`\n", + "\n", + "A cell is tagged as markup text by starting the cell with `%m3md` as this and the last cell do.\n", + "\n", + "Cells can be marked using the typical markup tags. For example, a first-level heading starts with `#` at the beginning of a line. \n", + "See the text of the previous cell for an example of this.\n", + "\n", + "A second-level heading is indicated by starting a line with `##`, as this cell does.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a5f29cc1-9b2a-49c7-8015-1d3dab563813", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " \n", + "## Basic Markdown Markup\n", + "Inside cells tagged as Markdown (or that start with `%m3md`), you can format or tag text using the syntax normally found in Markdown text. \n", + "\n", + "Here is an example: \n", + "\n", + "* *italicized text*, \n", + "* **bold text**\n", + "* ~strikedown text~, \n", + "* `code text`, and \n", + "* mathematical inline text: $\\sqrt{(x^2)}$\n", + "\n", + "--- \n", + "\n", + "Normal markdown text also supports lists (seen above), definition lists, ordered lists, task lists, URLs, and other things.\n", + "\n", + "See the [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/) for a more complete list.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md \n", + "## Basic Markdown Markup\n", + "Inside cells tagged as Markdown (or that start with `%m3md`), you can format or tag text using the syntax normally found in Markdown text. \n", + "\n", + "Here is an example: \n", + "\n", + "* *italicized text*, \n", + "* **bold text**\n", + "* ~strikedown text~, \n", + "* `code text`, and \n", + "* mathematical inline text: $\\sqrt{(x^2)}$\n", + "\n", + "--- \n", + "\n", + "Normal markdown text also supports lists (seen above), definition lists, ordered lists, task lists, URLs, and other things.\n", + "\n", + "See the [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/) for a more complete list." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "74900c89-6b81-4a59-99fa-e2dbd569f419", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Hiding Cell Input\n", + "\n", + "In the above, we have shown the Markdown input cells along with the Markdown output. \n", + "This was done for pedagogical reasons: so that you'd see how input relates to output.\n", + "\n", + "However, you may want to hide input data and just show output data. For example, most of the time Markdown is used to explain other information, and what you need to do to get descriptive text \n", + "formatted is unimportant. \n", + "\n", + "To do this, click on the vertical blue bar:
\n", + "\n", + "that is shown next to the cell input.\n", + "\n", + "In doing this, you should see `%m3md...` and a shorter blue bar. Clicking on the blue bar will expand the input cell text again.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Hiding Cell Input\n", + "\n", + "In the above, we have shown the Markdown input cells along with the Markdown output. \n", + "This was done for pedagogical reasons: so that you'd see how input relates to output.\n", + "\n", + "However, you may want to hide input data and just show output data. For example, most of the time Markdown is used to explain other information, and what you need to do to get descriptive text \n", + "formatted is unimportant. \n", + "\n", + "To do this, click on the vertical blue bar:
\n", + "\n", + "that is shown next to the cell input.\n", + "\n", + "In doing this, you should see `%m3md...` and a shorter blue bar. Clicking on the blue bar will expand the input cell text again." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "68400a11-cf9f-4e1a-8f22-242b81cdb793", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Notebook File Loading\n", + "\n", + "On entry of a pre-existing notebook, input cells and the output due to a _prior_ evaluation of cells are shown.\n", + "\n", + "However, internal values of any variables set due to a prior execution are lost. Therefore, it is often useful to hit the \n", + "menubar refresh button \n", + "\n", + " \n", + " \n", + " \n", + " \n", + "just to the left of the `Code` button. \n", + "\n", + "This will restart the Mathics3 Jupyter kernel and sequentially evaluate all of the cell input data. In the process, variables and \n", + "other state information will get set to the values as they appeared initially.\n", + "\n", + "To run cell input one by one, use the \n", + "\n", + " \n", + " \n", + " \n", + " \n", + "icon to the left of the restart button.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Notebook File Loading\n", + "\n", + "On entry of a pre-existing notebook, input cells and the output due to a _prior_ evaluation of cells are shown.\n", + "\n", + "However, internal values of any variables set due to a prior execution are lost. Therefore, it is often useful to hit the \n", + "menubar refresh button \n", + "\n", + " \n", + " \n", + " \n", + " \n", + "just to the left of the `Code` button. \n", + "\n", + "This will restart the Mathics3 Jupyter kernel and sequentially evaluate all of the cell input data. In the process, variables and \n", + "other state information will get set to the values as they appeared initially.\n", + "\n", + "To run cell input one by one, use the \n", + "\n", + " \n", + " \n", + " \n", + " \n", + "icon to the left of the restart button.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "30395023-6875-45f4-934c-f332ea71720f", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " ## Entering Mathics3 Expressions\n", + "\n", + "Finally, we get to inputting Mathics3 expressions and seeing its output!\n", + "\n", + "Until Jupyter markdown handling is integrated better with Mathics3, Mathics3 expressions have to be entered in a cell\n", + "separate from markdown.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md ## Entering Mathics3 Expressions\n", + "\n", + "Finally, we get to inputting Mathics3 expressions and seeing its output!\n", + "\n", + "Until Jupyter markdown handling is integrated better with Mathics3, Mathics3 expressions have to be entered in a cell\n", + "separate from markdown.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "11112071-ad5b-4a9c-b2d7-d797498659db", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle -1$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Compute Euler's famous equation: *)\n", + "E ^ (Pi I)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "345ff68b-0539-4fb9-9e3c-ff069f56d0b5", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + " \n", + "As seen above, you can add Mathics3 Comments before an expression.\n", + "\n", + "And of course, you can put them after an expression too:\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md \n", + "As seen above, you can add Mathics3 Comments before an expression.\n", + "\n", + "And of course, you can put them after an expression too:" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ecdc3965-79b1-4f90-956c-38553fc51c35", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 265252859812191058636308480000000$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "30! (* 30 Factorial. All Factorials over 5! have zeros at the end. *)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "1aec9da4-338c-4885-a587-581f3eabbb45", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "-6\n", + "-4\n", + "-2\n", + "2\n", + "4\n", + "6\n", + "\n", + "\n", + "\n", + "\n", + "-4\n", + "-2\n", + "2\n", + "4\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* The Mathics3 Jupyter Kernel supports Plotting ... *)\n", + "Plot[Csc[x], {x, -2Pi, 2Pi}]" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "4e8f74ba-4e40-41e6-8de0-8f3e9bfb50da", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lindenmayer[i_, b_, h_, j_, r_, n_] := \n", + " (a = h; p = j; s = k = {}; t = Flatten;\n", + " (Switch[#,\n", + " 6, s = {a, p, s},\n", + " 8, {a, p, s} = s,\n", + " _C, k = {k, Line@{p, p += {Cos@a, Sin@a}}}];\n", + " If[# < 9, a += I^# b ]) & /@ t@Nest[# /. r &, i, n];\n", + " Graphics@t@k);\n", + "lindenmayer[{C[1], X}, Pi/2, 0, {0, 0}, {X -> {X, 4, Y, C[1]}, Y -> {C[1], X, 2, Y}}, 7]" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "f22fda6f-12f2-4460-b1b9-ef63a1e698d7", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "Mathics3 has a lot more. In other notebooks, we show features that Mathics3 has to offer. \n", + "\n", + "Now let us show interaction with Python.\n", + "\n", + "## Python Magic (`%python` or `%py`)\n", + "\n", + "Mathics3 is built on top of Python. So if you want to escape back to running Python code, that can be done starting a cell with\n", + "either `%python` or the shorter `%py`:\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "Mathics3 has a lot more. In other notebooks, we show features that Mathics3 has to offer. \n", + "\n", + "Now let us show interaction with Python.\n", + "\n", + "## Python Magic (`%python` or `%py`)\n", + "\n", + "Mathics3 is built on top of Python. So if you want to escape back to running Python code, that can be done starting a cell with\n", + "either `%python` or the shorter `%py`:" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "448c461e-ae78-4f90-89c5-bc7969f50ee8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 3, 6, 10, 15]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%python \n", + "[(n * (n+1))// 2 for n in range(1, 6)] # Triangle numbers" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "3375a84b-2f38-4138-a332-641f4ab79977", + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\{1, 3, 6, 10, 15\\}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(* Same thing in Mathics3: *)\n", + "Table[n (n+1) / 2, {n, 5}]" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "e43b3ac3-68c8-4775-9c67-8b7ff52a0181", + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "Above, we gave a Python expression. However, Python statements are also accepted:\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "Above, we gave a Python expression. However, Python statements are also accepted:" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "ac50dd79-4825-4f81-b5f9-987f09a06adb", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "3\n", + "6\n", + "10\n", + "15\n" + ] + } + ], + "source": [ + "%py\n", + "# Compute the first 5 triangle numbers.\n", + "n = 5\n", + "for n in range(1, n + 1):\n", + " print(n * (n + 1) // 2)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "f100e734-88c7-4c41-87b5-1463b9e00378", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "data": { + "text/markdown": [ + "\n", + "\n", + "In Python, you have access to the global state available. One additional variable we provide is `session`.\n", + "This is the Mathics3 Session object. And from this, you basically have access at the Python level to everything.\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%m3md\n", + "In Python, you have access to the global state available. One additional variable we provide is `session`.\n", + "This is the Mathics3 Session object. And from this, you basically have access at the Python level to everything." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "2fcc617f-1d05-4b99-bd5f-c26bf145414c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1, 3, 6, 10, 15)" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%py \n", + "session.last_result.to_python()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "934ad245-8e71-4256-9a33-9449a1ec335d", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.14.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/index.html b/index.html index 1ec53bc..22f4f7e 100644 --- a/index.html +++ b/index.html @@ -327,7 +327,7 @@
-

Mathics3 Live Shell (1.0.1.a1)

+

Mathics3 Live Shell (1.0.1.a2)