{ "cells": [ { "cell_type": "markdown", "id": "1c5b0b35", "metadata": {}, "source": [ "# The Order of Partial Differentiation\n", "\n", "For a sufficiently smooth function, mixed partial derivatives\n", "commute. We illustrate Clairaut's theorem with\n", "\n", "$$\n", "f(x,y,z)=\\frac{x^5y^3}{z},\n", "$$\n", "\n", "differentiating once with respect to each variable in several\n", "orders.\n" ] }, { "cell_type": "markdown", "id": "2a7dd97d", "metadata": {}, "source": [ "## Define the function\n", "\n", "The explicit type annotation makes the symbolic domain clear to\n", "the Egison kernel.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "e994e177", "metadata": {}, "outputs": [], "source": [ "declare symbol x, y, z : MathValue\n", "\n", "def f (x : MathValue) (y : MathValue) (z : MathValue) : MathValue :=\n", " x^5 * y^3 / z\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "3f7c13e8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$x^{5} y^{3} z^{-1}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "f x y z\n" ] }, { "cell_type": "markdown", "id": "d03c8ce4", "metadata": {}, "source": [ "## A first mixed derivative\n", "\n", "Differentiating in the order $x$, then $y$, then $z$ should give\n", "\n", "$$\n", "\\partial_z\\partial_y\\partial_x f\n", " =-\\frac{15x^4y^2}{z^2}.\n", "$$\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "752fe2ba", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$-15 x^{4} y^{2} z^{-2}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "∂/∂ (∂/∂ (∂/∂ (f x y z) x) y) z\n" ] }, { "cell_type": "markdown", "id": "ed4e02d6", "metadata": {}, "source": [ "## Permuting the order\n", "\n", "We repeat the calculation with $z,y,x$ and $y,z,x$. Equality of\n", "all three outputs is the computational form of Clairaut's theorem\n", "on the region $z\\ne0$.\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "ac6a3511", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$-15 x^{4} y^{2} z^{-2}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "∂/∂ (∂/∂ (∂/∂ (f x y z) z) y) x\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "b2d326f9", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$-15 x^{4} y^{2} z^{-2}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "∂/∂ (∂/∂ (∂/∂ (f x y z) y) z) x\n" ] }, { "cell_type": "markdown", "id": "a49bb78e", "metadata": {}, "source": [ "Every order produces the same rational expression. The example\n", "also shows that Egison keeps the variables of differentiation\n", "explicit instead of encoding the order in auxiliary function names.\n" ] } ], "metadata": { "kernelspec": { "display_name": "Egison", "language": "egison", "name": "egison" }, "language_info": { "codemirror_mode": "egison", "file_extension": ".egi", "mimetype": "text/x-egison", "name": "egison" } }, "nbformat": 4, "nbformat_minor": 5 }