From b377c1aa2c176bce1138ce2cfa8927d99c434b7d Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Fri, 18 Oct 2024 11:51:26 +0200 Subject: [PATCH 1/7] added sympy --- book/{08 => 09}/asserts.ipynb | 0 book/{08 => 09}/error_types.ipynb | 0 book/{08 => 09}/handling_errors.ipynb | 0 book/{08 => 09}/intro.md | 0 book/{08 => 09}/raise_errors.ipynb | 0 book/{08 => 09}/traceback.ipynb | 0 book/_toc.yml | 16 +++++++++------- .../year2 => book}/sympy/sympy.ipynb | 0 .../year2 => book}/sympy/sympy_stripped.ipynb | 0 9 files changed, 9 insertions(+), 7 deletions(-) rename book/{08 => 09}/asserts.ipynb (100%) rename book/{08 => 09}/error_types.ipynb (100%) rename book/{08 => 09}/handling_errors.ipynb (100%) rename book/{08 => 09}/intro.md (100%) rename book/{08 => 09}/raise_errors.ipynb (100%) rename book/{08 => 09}/traceback.ipynb (100%) rename {other_python_stuff/year2 => book}/sympy/sympy.ipynb (100%) rename {other_python_stuff/year2 => book}/sympy/sympy_stripped.ipynb (100%) diff --git a/book/08/asserts.ipynb b/book/09/asserts.ipynb similarity index 100% rename from book/08/asserts.ipynb rename to book/09/asserts.ipynb diff --git a/book/08/error_types.ipynb b/book/09/error_types.ipynb similarity index 100% rename from book/08/error_types.ipynb rename to book/09/error_types.ipynb diff --git a/book/08/handling_errors.ipynb b/book/09/handling_errors.ipynb similarity index 100% rename from book/08/handling_errors.ipynb rename to book/09/handling_errors.ipynb diff --git a/book/08/intro.md b/book/09/intro.md similarity index 100% rename from book/08/intro.md rename to book/09/intro.md diff --git a/book/08/raise_errors.ipynb b/book/09/raise_errors.ipynb similarity index 100% rename from book/08/raise_errors.ipynb rename to book/09/raise_errors.ipynb diff --git a/book/08/traceback.ipynb b/book/09/traceback.ipynb similarity index 100% rename from book/08/traceback.ipynb rename to book/09/traceback.ipynb diff --git a/book/_toc.yml b/book/_toc.yml index 0460da4..7675181 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -42,14 +42,16 @@ parts: sections: - file: 07/Exercises/01.ipynb - file: 07/Exercises/bug_report.md - - file: 08/intro.md - title: 8. Errors + - file: 08/sympy + title: 8. SymPy + - file: 09/intro.md + title: 9. Errors sections: - - file: 08/error_types.ipynb - - file: 08/traceback.ipynb - - file: 08/raise_errors.ipynb - - file: 08/handling_errors.ipynb - - file: 08/asserts.ipynb + - file: 09/error_types.ipynb + - file: 09/traceback.ipynb + - file: 09/raise_errors.ipynb + - file: 09/handling_errors.ipynb + - file: 09/asserts.ipynb - caption: End of course survey chapters: - file: End-of-course-survey.md diff --git a/other_python_stuff/year2/sympy/sympy.ipynb b/book/sympy/sympy.ipynb similarity index 100% rename from other_python_stuff/year2/sympy/sympy.ipynb rename to book/sympy/sympy.ipynb diff --git a/other_python_stuff/year2/sympy/sympy_stripped.ipynb b/book/sympy/sympy_stripped.ipynb similarity index 100% rename from other_python_stuff/year2/sympy/sympy_stripped.ipynb rename to book/sympy/sympy_stripped.ipynb From 2ada7b7ffa10533c658a0d0fdbff1d00d87fdf24 Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Fri, 18 Oct 2024 11:55:34 +0200 Subject: [PATCH 2/7] Update references.bib --- book/references.bib | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/book/references.bib b/book/references.bib index 783ec6a..64196b9 100644 --- a/book/references.bib +++ b/book/references.bib @@ -54,3 +54,17 @@ @book{ruby year = {2008}, publisher = {O'Reilly Media} } + +@misc{sympy_why, + title={Sympy documentation}, + author={{SymPy Development Team}}, + howpublished={\url{https://docs.sympy.org/latest/tutorials/intro-tutorial/intro.html}}, + year={2023} +} + +@misc{jason_moore, + title={Learn Multibody Dynamics, SymPy}, + author={Moore, Jason}, + howpublished={\url{https://moorepants.github.io/learn-multibody-dynamics/sympy.html}}, + year={2023} +} \ No newline at end of file From cf2136132259ec861d58f1814f1bd24bafc8e992 Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Fri, 18 Oct 2024 11:55:57 +0200 Subject: [PATCH 3/7] Update _toc.yml --- book/_toc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/_toc.yml b/book/_toc.yml index 7675181..6c73927 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -42,7 +42,7 @@ parts: sections: - file: 07/Exercises/01.ipynb - file: 07/Exercises/bug_report.md - - file: 08/sympy + - file: 08/sympy/sympy title: 8. SymPy - file: 09/intro.md title: 9. Errors From b30eab5d7bb13a6d2a24e68b67da494410495df2 Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Fri, 18 Oct 2024 12:01:27 +0200 Subject: [PATCH 4/7] renamed folder --- book/{sympy => 08}/sympy.ipynb | 0 book/{sympy => 08}/sympy_stripped.ipynb | 0 book/_toc.yml | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename book/{sympy => 08}/sympy.ipynb (100%) rename book/{sympy => 08}/sympy_stripped.ipynb (100%) diff --git a/book/sympy/sympy.ipynb b/book/08/sympy.ipynb similarity index 100% rename from book/sympy/sympy.ipynb rename to book/08/sympy.ipynb diff --git a/book/sympy/sympy_stripped.ipynb b/book/08/sympy_stripped.ipynb similarity index 100% rename from book/sympy/sympy_stripped.ipynb rename to book/08/sympy_stripped.ipynb diff --git a/book/_toc.yml b/book/_toc.yml index 6c73927..7675181 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -42,7 +42,7 @@ parts: sections: - file: 07/Exercises/01.ipynb - file: 07/Exercises/bug_report.md - - file: 08/sympy/sympy + - file: 08/sympy title: 8. SymPy - file: 09/intro.md title: 9. Errors From 22e253473d8f59cde0732f57da995eb185e9059e Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Fri, 18 Oct 2024 12:04:35 +0200 Subject: [PATCH 5/7] Update references.bib --- book/references.bib | 3 --- 1 file changed, 3 deletions(-) diff --git a/book/references.bib b/book/references.bib index 64196b9..dba96ce 100644 --- a/book/references.bib +++ b/book/references.bib @@ -1,6 +1,3 @@ ---- ---- - @inproceedings{holdgraf_evidence_2014, address = {Brisbane, Australia, Australia}, title = {Evidence for {Predictive} {Coding} in {Human} {Auditory} {Cortex}}, From 41e837289778f5084c4bc57f5dc1800fd4dd936f Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Mon, 21 Oct 2024 10:42:49 +0200 Subject: [PATCH 6/7] Update sympy.ipynb --- book/08/sympy.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/08/sympy.ipynb b/book/08/sympy.ipynb index d149413..c11abc9 100644 --- a/book/08/sympy.ipynb +++ b/book/08/sympy.ipynb @@ -1139,7 +1139,7 @@ "source": [ ":::{card} Test yourself!\n", "\n", - "Create a symbolic expression representing [Newton's Law of Universal Gravitation](https://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation). Use `sym.lambdify()` to evaluate the expression for two mass of 5.972E24 kg and 80 kg at a distance of 6371 km apart to find the gravitational force in Newtons. $G$ equals $6.67430\\cdot 10 ^{11}$\n", + "Create a symbolic expression representing [Newton's Law of Universal Gravitation](https://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation). Use `sym.lambdify()` to evaluate the expression for two mass of 5.972E24 kg and 80 kg at a distance of 6371 km apart to find the gravitational force in Newtons. $G$ equals $6.67430\\cdot 10 ^{-11}$\n", "\n", "All variables have been defined with:\n", "```python\n", From 5c2e8036df1805d28855855a7259a54ddc624359 Mon Sep 17 00:00:00 2001 From: Robert Lanzafame Date: Tue, 22 Oct 2024 10:29:45 +0200 Subject: [PATCH 7/7] 2 edits --- book/08/sympy.ipynb | 27 +++++++++++++++++++++++++-- book/08/sympy_stripped.ipynb | 20 ++++++++++---------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/book/08/sympy.ipynb b/book/08/sympy.ipynb index c11abc9..e816417 100644 --- a/book/08/sympy.ipynb +++ b/book/08/sympy.ipynb @@ -409,14 +409,37 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Notice something in the above example. When we typed `expr - x`, we did not get $x + 2y - x$, but rather just $2y$. The $x$ and the $-x$ automatically canceled one another. This is similar to how $\\sqrt{8}$ automatically turned into $2\\sqrt{2}$ above. This isn’t always the case in SymPy; Aside from obvious simplifications like $x - x = 0$ and $\\sqrt{8} = 2\\sqrt{2}$, most simplifications are not performed automatically. " + "Notice something in the above example. When we typed `expr - x`, we did not get $x + 2y - x$, but rather just $2y$. The $x$ and the $-x$ automatically canceled one another. This is similar to how $\\sqrt{8}$ automatically turned into $2\\sqrt{2}$ above. This isn’t always the case in SymPy, however; consider this example:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFgAAAAVCAYAAADCUymGAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD3klEQVRYCd2Y0VEbMRCGL4wL8FCC6YCECmJ3QEgFCR04kyf8xjgdABVkQgeQCojpwO4gHndA/k8naWRZd8Hn9RCyM3uSVtKvvdXuSnfV09NTZc0XFxcDa8zXgFd674PKmCaTyViQx8awrwVu4N8/6vsGz7AigZ8K60TlFyvMfeJIz4Hwg67vVF/Slvyx67qai4OtVF6DYWZgAfaF91PlW4D/dZKeGPdK5SjoqvpUdQw0Uv0+yLctNXemOe9VrixTBMpdbavMLuP1AkPx544Y6HuezhUW3rwS/0jlHerYAfzK0sBnUtCFRQeFuk4hauAuNNSkuXTO5+O5fcnx8E7k7YA9+iYGFhC5d9FJm5ebhCEX0h2PLVFu+NKYNhn2OOuFEVhb9RBuJ6p/ErOLH8XQg8bc1tWNJ3msMWftiL2xmIVAOn1owHE3IPW7gy7R/UjjZ2rHKPV9NypLWNhjlHrwVAO/wep4EN+IyXHkJYzvcorKEnECz0sdXrYLdgusbZfeFePiVOFmwQJfvU3uVM9tcCYZ0Vsi7DFwHiwAPDedTNgwES+GDsVpvxMmDzaAK84GGWBvYO5RwOF26w1aqcTgOBtElObv2Ba5jK0NrMovgaU5lKvWo2QYmoVKIUBXIDbAjQ2CpNwVm/U5lTmUcmJd+tduA34Q+v9N74jn1yAnp3Nou1ShgXjrZZxQV9Apl4Uh2LMfPDiAhM4SWOjbqkwUDPO2xhZGyYCV5EQZX0+ktc6k+UTwoUo8MpLawcEwJFGa5l+8G1nT2eOcLs3BGuu8IYDFA00LcW0BrIkIh7Z+N08YXbCb1jSRSyc26Uhl9FzV2TRycSD6YkR7Ie/CF1vunGEO9lj2NIAKuYeDiN3AW5iYpgwSfZr4NWSNGJsq5DqNsNcWsmxIP7yw9GmP0aO3qs67pfZQ0+XkJu+lHw9e9PRgJ2C+wZ3VVY8kGX0h0Ud5VmEXTzIZTQvsAuzuIr0XRsOx7lXPv0CHkqVpB+NiMEfeJrxbMXX5Ye4c66nBLrBbTKg0+Vx8J2ZRvqmXqsd0wZgCfZcMZXOywM4xrdpcuzByuPunuHnYE73cd7lJ/RZzJ4baPLjeAKv/rPoXOhcfW+E9B0frnYrHzxlrOUZrTsWzJkz1DcRz+g/qjTB5srttIWOySAayUhveG+G1YiLZkeqkUbz+spYUn3i8+24wM7AWJs3kp29xdSuh1iR/poeRFXSKw4FHCgzEF+611i2mTclJO9jB6UUOtiSuM+Titfuk5QIvgIU3ckceqyT38g+5LfdydsVINvvhLlBHfgdPVaancOj+r0u/CXxqxyvdHwOidMKb8DIVAAAAAElFTkSuQmCC", + "text/latex": [ + "$\\displaystyle x \\left(x + 2 y\\right)$" + ], + "text/plain": [ + "x⋅(x + 2⋅y)" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "x*expr" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "A general formula to simplify formulas is `sym.simplify`, which attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression:" + "Aside from obvious simplifications like $x - x = 0$ and $\\sqrt{8} = 2\\sqrt{2}$, most simplifications are not performed automatically. A general formula to simplify formulas is `sym.simplify`, which attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression:" ] }, { diff --git a/book/08/sympy_stripped.ipynb b/book/08/sympy_stripped.ipynb index cadd9ee..49dc90f 100644 --- a/book/08/sympy_stripped.ipynb +++ b/book/08/sympy_stripped.ipynb @@ -313,7 +313,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Notice something in the above example. When we typed `expr - x`, we did not get $x + 2y - x$, but rather just $2y$. The $x$ and the $-x$ automatically canceled one another. This is similar to how $\\sqrt{8}$ automatically turned into $2\\sqrt{2}$ above. This isn’t always the case in SymPy, however:" + "Notice something in the above example. When we typed `expr - x`, we did not get $x + 2y - x$, but rather just $2y$. The $x$ and the $-x$ automatically canceled one another. This is similar to how $\\sqrt{8}$ automatically turned into $2\\sqrt{2}$ above. This isn’t always the case in SymPy, however; consider this example:" ] }, { @@ -344,14 +344,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Notice something in the above example. When we typed `expr - x`, we did not get $x + 2y - x$, but rather just $2y$. The $x$ and the $-x$ automatically canceled one another. This is similar to how $\\sqrt{8}$ automatically turned into $2\\sqrt{2}$ above. This isn’t always the case in SymPy; Aside from obvious simplifications like $x - x = 0$ and $\\sqrt{8} = 2\\sqrt{2}$, most simplifications are not performed automatically. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "A general formula to simplify formulas is `sym.simplify`, which attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression:" + "Aside from obvious simplifications like $x - x = 0$ and $\\sqrt{8} = 2\\sqrt{2}$, most simplifications are not performed automatically. A general formula to simplify formulas is `sym.simplify`, which attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression:" ] }, { @@ -516,7 +509,13 @@ "\n", "Create an expression for the normal distribution function:\n", "\n", - "$$\\frac{1}{\\sqrt{2\\pi\\sigma}}e^{\\frac{(x-\\mu)^2}{2\\sigma^2}}$$" + "$$\\frac{1}{\\sqrt{2\\pi\\sigma}}e^{\\frac{(x-\\mu)^2}{2\\sigma^2}}$$\n", + "\n", + "First define variables with:\n", + "\n", + "```python\n", + "sym.var('x, sigma, mu')\n", + "```" ] }, { @@ -525,6 +524,7 @@ "metadata": {}, "outputs": [], "source": [ + "# define variables\n", "expr = \n", "expr #displays expression" ]