{ "cells": [ { "cell_type": "markdown", "id": "ce1b1289", "metadata": {}, "source": [ "# Vector Analysis with Tensor Derivatives\n", "\n", "Gradient, Jacobian, divergence, and curl are different arrangements of\n", "the same partial derivatives. Egison's tensor notation makes those\n", "arrangements explicit and keeps the symbolic expressions readable.\n" ] }, { "cell_type": "markdown", "id": "2aa3e747", "metadata": {}, "source": [ "## Scalar and vector fields\n", "\n", "We use a polynomial scalar field and a vector field on $\\mathbb R^3$ so\n", "every derivative remains symbolic but has an easily interpretable form.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "3cd7f5c8", "metadata": {}, "outputs": [], "source": [ "declare symbol x, y, z : MathValue\n", "\n", "def coords : Vector MathValue := [| x, y, z |]\n", "def f : MathValue := x ^ 2 * y + y ^ 2 * z + z ^ 2 * x\n", "def A : Vector MathValue := [| x * y, y * z, z * x |]\n" ] }, { "cell_type": "markdown", "id": "d1330125", "metadata": {}, "source": [ "## Gradient\n", "\n", "Differentiating a scalar with respect to the coordinate vector produces\n", "the covector of first partial derivatives.\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "2430d10f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$\\begin{pmatrix} z^{2} + 2 x y \\\\ 2 y z + x^{2} \\\\ y^{2} + 2 x z\\\\ \\end{pmatrix}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "∂/∂ f coords\n" ] }, { "cell_type": "markdown", "id": "aef47cfc", "metadata": {}, "source": [ "## Jacobian\n", "\n", "A vector of derivative operators applied to a vector field produces the\n", "full Jacobian matrix. Rows correspond to differentiation by\n", "$x$, $y$, and $z$.\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "4e9a48d3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$\\begin{pmatrix} y & 0 & z \\\\ x & z & 0 \\\\ 0 & y & x \\\\ \\end{pmatrix}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "[| (\\e -> ∂/∂ e x), (\\e -> ∂/∂ e y), (\\e -> ∂/∂ e z) |] A\n" ] }, { "cell_type": "markdown", "id": "ae4a3e89", "metadata": {}, "source": [ "## Divergence\n", "\n", "Divergence contracts the derivative index with the vector-component\n", "index:\n", "\n", "$$\\nabla\\cdot A=\\partial_x A_x+\\partial_y A_y+\\partial_z A_z.$$\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "594092a2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$z + y + x$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "div A coords\n" ] }, { "cell_type": "markdown", "id": "6524bb7f", "metadata": {}, "source": [ "## Curl\n", "\n", "Curl contracts the Jacobian with the Levi-Civita tensor,\n", "$(\\nabla\\times A)_i=\\varepsilon_{ijk}\\partial_jA_k$.\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "596409cc", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$\\begin{pmatrix} -y \\\\ -z \\\\ -x\\\\ \\end{pmatrix}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "rot A coords\n" ] }, { "cell_type": "markdown", "id": "6e7a53a2", "metadata": {}, "source": [ "## A local series view\n", "\n", "Tensor calculus and series expansion share the same symbolic derivative\n", "machinery. Expanding $f$ in $x$ about zero treats $y$ and $z$ as\n", "parameters.\n" ] }, { "cell_type": "code", "execution_count": 6, "id": "9dd62aed", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$\\{y^{2} z, x z^{2}, x^{2} y, 0\\}$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "take 4 (taylorExpansion f x 0)\n" ] }, { "cell_type": "markdown", "id": "62bed616", "metadata": {}, "source": [ "The gradient retains every first derivative, the divergence selects the\n", "Jacobian trace, and the curl selects its antisymmetric part. These are\n", "therefore not unrelated operators: they are distinct contractions and\n", "symmetries of one derivative tensor.\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 }