{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from galgebra.printer import Format\n", "from galgebra.ga import Ga\n", "from sympy import symbols" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "Format()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "coords = (x,y,z) = symbols('x,y,z',real=True)\n", "(o3d,ex,ey,ez) = Ga.build('e_x e_y e_z',g=[1,1,1],coords=coords)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "v = o3d.mv('v','vector')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} v = v^{x} \\boldsymbol{e}_{x} + v^{y} \\boldsymbol{e}_{y} + v^{z} \\boldsymbol{e}_{z} \\end{equation*}" ], "text/plain": [ "v__x*e_x + v__y*e_y + v__z*e_z" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} v = \\begin{aligned}[t] & v^{x} \\boldsymbol{e}_{x} \\\\ & + v^{y} \\boldsymbol{e}_{y} \\\\ & + v^{z} \\boldsymbol{e}_{z} \\end{aligned} \\end{equation*}" ], "text/plain": [ "v = v__x*e_x\n", " + v__y*e_y\n", " + v__z*e_z" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v.Fmt(3,'v')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "V = o3d.mv('V','vector',f=True)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} V^{x} \\boldsymbol{e}_{x} + V^{y} \\boldsymbol{e}_{y} + V^{z} \\boldsymbol{e}_{z} \\end{equation*}" ], "text/plain": [ "V__x*e_x + V__y*e_y + V__z*e_z" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "V.Fmt()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} V = V^{x} \\boldsymbol{e}_{x} + V^{y} \\boldsymbol{e}_{y} + V^{z} \\boldsymbol{e}_{z} \\end{equation*}" ], "text/plain": [ "V__x*e_x + V__y*e_y + V__z*e_z" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "V" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "gradV = o3d.grad*V" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} \\left ( \\partial_{x} V^{x} + \\partial_{y} V^{y} + \\partial_{z} V^{z} \\right ) + \\left ( - \\partial_{y} V^{x} + \\partial_{x} V^{y} \\right ) \\boldsymbol{e}_{x}\\wedge \\boldsymbol{e}_{y} + \\left ( - \\partial_{z} V^{x} + \\partial_{x} V^{z} \\right ) \\boldsymbol{e}_{x}\\wedge \\boldsymbol{e}_{z} + \\left ( - \\partial_{z} V^{y} + \\partial_{y} V^{z} \\right ) \\boldsymbol{e}_{y}\\wedge \\boldsymbol{e}_{z} \\end{equation*}" ], "text/plain": [ "D{x}V__x + D{y}V__y + D{z}V__z + (-D{y}V__x + D{x}V__y)*e_x^e_y + (-D{z}V__x + D{x}V__z)*e_x^e_z + (-D{z}V__y + D{y}V__z)*e_y^e_z" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gradV" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} \\nabla V = \\begin{aligned}[t] & \\left ( \\partial_{x} V^{x} + \\partial_{y} V^{y} + \\partial_{z} V^{z} \\right ) \\\\ & + \\left ( - \\partial_{y} V^{x} + \\partial_{x} V^{y} \\right ) \\boldsymbol{e}_{x}\\wedge \\boldsymbol{e}_{y} \\\\ & + \\left ( - \\partial_{z} V^{x} + \\partial_{x} V^{z} \\right ) \\boldsymbol{e}_{x}\\wedge \\boldsymbol{e}_{z} \\\\ & + \\left ( - \\partial_{z} V^{y} + \\partial_{y} V^{z} \\right ) \\boldsymbol{e}_{y}\\wedge \\boldsymbol{e}_{z} \\end{aligned} \\end{equation*}" ], "text/plain": [ "\\nabla V = D{x}V__x + D{y}V__y + D{z}V__z\n", " + (-D{y}V__x + D{x}V__y)*e_x^e_y\n", " + (-D{z}V__x + D{x}V__z)*e_x^e_z\n", " + (-D{z}V__y + D{y}V__z)*e_y^e_z" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gradV.Fmt(3,r'\\nabla V')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} \\nabla V = \\begin{aligned}[t] & \\left ( \\partial_{x} V^{x} + \\partial_{y} V^{y} + \\partial_{z} V^{z} \\right ) \\\\ & + \\left ( - \\partial_{y} V^{x} + \\partial_{x} V^{y} \\right ) \\boldsymbol{e}_{x}\\wedge \\boldsymbol{e}_{y} + \\left ( - \\partial_{z} V^{x} + \\partial_{x} V^{z} \\right ) \\boldsymbol{e}_{x}\\wedge \\boldsymbol{e}_{z} + \\left ( - \\partial_{z} V^{y} + \\partial_{y} V^{z} \\right ) \\boldsymbol{e}_{y}\\wedge \\boldsymbol{e}_{z} \\end{aligned} \\end{equation*}" ], "text/plain": [ "\\nabla V = D{x}V__x + D{y}V__y + D{z}V__z\n", " + (-D{y}V__x + D{x}V__y)*e_x^e_y + (-D{z}V__x + D{x}V__z)*e_x^e_z + (-D{z}V__y + D{y}V__z)*e_y^e_z" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gradV.Fmt(2,r'\\nabla V')" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "lap = o3d.grad|o3d.grad" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} \\frac{\\partial^{2}}{\\partial x^{2}} + \\frac{\\partial^{2}}{\\partial y^{2}} + \\frac{\\partial^{2}}{\\partial z^{2}} \\end{equation*}" ], "text/plain": [ "D{x}^2 + D{y}^2 + D{z}^2" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lap" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} \\nabla^{2} = \\frac{\\partial^{2}}{\\partial x^{2}} + \\frac{\\partial^{2}}{\\partial y^{2}} + \\frac{\\partial^{2}}{\\partial z^{2}} \\end{equation*}" ], "text/plain": [ "\\nabla^{2} = D{x}^2 + D{y}^2 + D{z}^2" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lap.Fmt(1,'\\\\nabla^{2}')" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "scrolled": false }, "outputs": [], "source": [ "A = o3d.lt('A')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} \\left \\{ \\begin{array}{ll} L \\left ( \\boldsymbol{e}_{x}\\right ) =& A_{xx} \\boldsymbol{e}_{x} + A_{yx} \\boldsymbol{e}_{y} + A_{zx} \\boldsymbol{e}_{z} \\\\ L \\left ( \\boldsymbol{e}_{y}\\right ) =& A_{xy} \\boldsymbol{e}_{x} + A_{yy} \\boldsymbol{e}_{y} + A_{zy} \\boldsymbol{e}_{z} \\\\ L \\left ( \\boldsymbol{e}_{z}\\right ) =& A_{xz} \\boldsymbol{e}_{x} + A_{yz} \\boldsymbol{e}_{y} + A_{zz} \\boldsymbol{e}_{z} \\end{array} \\right \\} \n", " \\end{equation*}" ], "text/plain": [ "Lt(e_x) = A_xx*e_x + A_yx*e_y + A_zx*e_z\n", "Lt(e_y) = A_xy*e_x + A_yy*e_y + A_zy*e_z\n", "Lt(e_z) = A_xz*e_x + A_yz*e_y + A_zz*e_z" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} A = \\left \\{ \\begin{array}{ll} L \\left ( \\boldsymbol{e}_{x}\\right ) =& A_{xx} \\boldsymbol{e}_{x} + A_{yx} \\boldsymbol{e}_{y} + A_{zx} \\boldsymbol{e}_{z} \\\\ L \\left ( \\boldsymbol{e}_{y}\\right ) =& A_{xy} \\boldsymbol{e}_{x} + A_{yy} \\boldsymbol{e}_{y} + A_{zy} \\boldsymbol{e}_{z} \\\\ L \\left ( \\boldsymbol{e}_{z}\\right ) =& A_{xz} \\boldsymbol{e}_{x} + A_{yz} \\boldsymbol{e}_{y} + A_{zz} \\boldsymbol{e}_{z} \\end{array} \\right \\} \n", " \\end{equation*}" ], "text/plain": [ "A = Lt(e_x) = A_xx*e_x + A_yx*e_y + A_zx*e_z\n", "Lt(e_y) = A_xy*e_x + A_yy*e_y + A_zy*e_z\n", "Lt(e_z) = A_xz*e_x + A_yz*e_y + A_zz*e_z" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A.Fmt(1,'A')" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{equation*} A = \\left \\{ \\begin{array}{ll} L \\left ( \\boldsymbol{e}_{x}\\right ) =& A_{xx} \\boldsymbol{e}_{x} + A_{yx} \\boldsymbol{e}_{y} + A_{zx} \\boldsymbol{e}_{z} \\\\ L \\left ( \\boldsymbol{e}_{y}\\right ) =& A_{xy} \\boldsymbol{e}_{x} + A_{yy} \\boldsymbol{e}_{y} + A_{zy} \\boldsymbol{e}_{z} \\\\ L \\left ( \\boldsymbol{e}_{z}\\right ) =& A_{xz} \\boldsymbol{e}_{x} + A_{yz} \\boldsymbol{e}_{y} + A_{zz} \\boldsymbol{e}_{z} \\end{array} \\right \\} \n", " \\end{equation*}" ], "text/plain": [ "A = Lt(e_x) = A_xx*e_x + A_yx*e_y + A_zx*e_z\n", "Lt(e_y) = A_xy*e_x + A_yy*e_y + A_zy*e_z\n", "Lt(e_z) = A_xz*e_x + A_yz*e_y + A_zz*e_z" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A.Fmt(2,'A')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.0" } }, "nbformat": 4, "nbformat_minor": 1 }