{ "cells": [ { "cell_type": "markdown", "id": "bd06312f-a5d4-4a37-b9e3-dc6526a3071c", "metadata": {}, "source": [ "[Oregon Curriculum Network](http://4dsolutions.net/ocn/)
\n", "[School of Tomorrow](School_of_Tomorrow.ipynb)\n", "\n", "\n", "# Koski Sums (\"Phi-dentities\")\n", "\n", "The sympy simplifier, on its own, just makes baroque expressions, but if confronted with $\\sqrt{2}$ and $\\sqrt{3}$ as equalities, [as suggested on StackOverFlow](https://stackoverflow.com/questions/37112738/sympy-comparing-expressions#37115190), the identities are confirmed." ] }, { "cell_type": "code", "execution_count": 1, "id": "1c685ef6-3d88-44b0-8af9-324aa3f7ca7d", "metadata": {}, "outputs": [], "source": [ "import sympy as sym" ] }, { "cell_type": "code", "execution_count": 2, "id": "1f6a6540-d63a-43dd-8ce4-04fb6a00fb4e", "metadata": {}, "outputs": [], "source": [ "ϕ = sym.Symbol('ϕ')" ] }, { "cell_type": "markdown", "id": "1127c6a9-0e64-439d-9b4e-9706b863d3e5", "metadata": {}, "source": [ "This will be $\\sqrt{2}$:" ] }, { "cell_type": "code", "execution_count": 3, "id": "434a3938-ca65-466c-8e40-c7bcdadea44d", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\sqrt{ϕ + \\frac{1}{ϕ^{2}}}$" ], "text/plain": [ "sqrt(ϕ + ϕ**(-2))" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e = sym.sqrt(ϕ + ϕ**-2)\n", "e" ] }, { "cell_type": "markdown", "id": "f44614f5-a851-4cfd-abe5-7e298c881e8e", "metadata": {}, "source": [ "This will be $\\sqrt{3}$:" ] }, { "cell_type": "code", "execution_count": 4, "id": "93090737-cc80-47ca-9120-0379f8487c22", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\sqrt{ϕ^{2} + \\frac{1}{ϕ^{2}}}$" ], "text/plain": [ "sqrt(ϕ**2 + ϕ**(-2))" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e2 = sym.sqrt(ϕ**2 + ϕ**-2)\n", "e2" ] }, { "cell_type": "code", "execution_count": 5, "id": "7c087d8f-1bb9-4a22-a306-7c215137b556", "metadata": {}, "outputs": [], "source": [ "ϕ = (sym.sqrt(5)+1)/2 # real value time!" ] }, { "cell_type": "code", "execution_count": 6, "id": "e22a90e1-4c5d-4597-8b8d-27641f3fdd6a", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1.6180339887498948482045868343656381177203091798058$" ], "text/plain": [ "1.6180339887498948482045868343656381177203091798058" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ϕ.evalf(50)" ] }, { "cell_type": "markdown", "id": "04b8118b-e401-4812-8b26-66c2d6ed6afc", "metadata": {}, "source": [ "# Checking $\\sqrt{2}$" ] }, { "cell_type": "code", "execution_count": 7, "id": "314ab19e-dbb4-4e00-abf3-564125f1ef42", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\sqrt{\\frac{1}{\\left(\\frac{1}{2} + \\frac{\\sqrt{5}}{2}\\right)^{2}} + \\frac{1}{2} + \\frac{\\sqrt{5}}{2}}$" ], "text/plain": [ "sqrt((1/2 + sqrt(5)/2)**(-2) + 1/2 + sqrt(5)/2)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e = sym.sqrt(ϕ + ϕ**-2)\n", "e" ] }, { "cell_type": "code", "execution_count": 8, "id": "e2562ef0-7130-436a-b6cb-fd67d6dba3f0", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1.4142135623730950488016887242096980785696718753769$" ], "text/plain": [ "1.4142135623730950488016887242096980785696718753769" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e.evalf(50)" ] }, { "cell_type": "code", "execution_count": 9, "id": "c5a38d37-c1b0-4256-9563-f3e487cfc973", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1.4142135623730950488016887242096980785696718753769$" ], "text/plain": [ "1.4142135623730950488016887242096980785696718753769" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sym.N(sym.sqrt(2), 50)" ] }, { "cell_type": "code", "execution_count": 10, "id": "104c6dbc-36cd-46ab-a402-7cac2afbd53a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e.equals(sym.sqrt(2))" ] }, { "cell_type": "markdown", "id": "92c55ed4-ccd2-42ef-bf1d-e33f3128c036", "metadata": {}, "source": [ "# Checking $\\sqrt{3}$" ] }, { "cell_type": "code", "execution_count": 11, "id": "0cfb34a2-2a08-4df3-ba2c-457af947e0b5", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\sqrt{\\frac{1}{\\left(\\frac{1}{2} + \\frac{\\sqrt{5}}{2}\\right)^{2}} + \\left(\\frac{1}{2} + \\frac{\\sqrt{5}}{2}\\right)^{2}}$" ], "text/plain": [ "sqrt((1/2 + sqrt(5)/2)**(-2) + (1/2 + sqrt(5)/2)**2)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e2 = sym.sqrt(ϕ**2 + ϕ**-2)\n", "e2" ] }, { "cell_type": "code", "execution_count": 12, "id": "e4761877-2532-477f-8221-0f15bca0fdca", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1.7320508075688772935274463415058723669428052538104$" ], "text/plain": [ "1.7320508075688772935274463415058723669428052538104" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e2.evalf(50)" ] }, { "cell_type": "code", "execution_count": 13, "id": "8f323c1c-8d22-402c-8270-c48e0a185e5d", "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle 1.7320508075688772935274463415058723669428052538104$" ], "text/plain": [ "1.7320508075688772935274463415058723669428052538104" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sym.N(sym.sqrt(3), 50)" ] }, { "cell_type": "code", "execution_count": 14, "id": "d218c157-241e-475f-aec7-870900ef26aa", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e2.equals(sym.sqrt(3))" ] } ], "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.9.12" } }, "nbformat": 4, "nbformat_minor": 5 }