{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n", "from clifford import * \n", "\n", "pretty()\n", "layout, blades = Cl(3,1)\n", "\n", "rb = lambda g:randomMV(layout, grades=[g])\n", "eps(1e-11)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Conformal Space" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Vectors in the orignal space are mapped to vectors in conformal space through the map:\n", "\n", "$X = x + \\frac{1}{2} x^2 e_{\\infty} +e_o $\n", "\n", "\n", "The inverse map is the made by normalizing the conformal vector, then rejection from the minkowski plane $E_0$,\n", "\n", "\n", "$ X = \\frac{X}{X \\cdot e_{\\infty}}$\n", "\n", "then \n", "\n", "$x = X \\wedge E_0\\, E_0^{-1}$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "e0,e1,e2,e3 = [blades['e%i'%k] for k in range(4)]\n", "\n", "# setup null basis, and minkowski subspace bivector\n", "eo = .5^(e3-e2)\n", "einf= e2+e3\n", "E0= einf^eo\n", "\n", "\n", "v4 = lambda : rb(1)\n", "\n", "def v2():\n", " x=v4()\n", " return x- E0.project(x)\n", "\n", "up = lambda x: x + (.5^((x**2)*einf)) + eo\n", "homo = lambda x: x * (-x|einf).normalInv() # homogenise conformal vector\n", "down = lambda x: (homo(x)^E0)*E0\n", "\n", "c2v = lambda x: (x.real*e0) + (x.imag*e1) # complex2vector\n", "v2c = lambda x: float(x|e0)+ float(x|e1)*1j\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "eo^einf == -E0" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "eo" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "einf*eo" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "einf-(2^eo)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "x = v2()\n", "x" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "X=up(x)\n", "X" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "x = v2()\n", "X = up(x)\n", "assert(X**2 ==0)\n", "assert(down(X) ==x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Operations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Conformal transformations in $G^n$ are achieved through versers in the conformal space $G^{n+1,1}$. These versers can be categorized by their relation to the added minkowski plane, $E_0$. There are three categories,\n", "\n", "* verser purley in $E_0$\n", "* verser partly in $E_0$\n", "* verser out of $E_0$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.display import Image,SVG\n", "Image('img/conformal space.png')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Versers purely in $E_0$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "eps(1e-13)\n", "a = v2()\n", "b = v2()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Inversions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$ e_+ X e_+$\n", "\n", "Inversion is a reflection in hyperplane normal to $e_-$, this swaps $e_o$ and $e_{\\infty}$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "assert(down(e2&up(a)&e2) == a.inv())\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Involutions " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$E_0 X E_0$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "assert(down(E0&up(a)&E0) == -a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dialations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$D_\\alpha = e^{-\\frac{\\ln{\\alpha}}{2} \\,E_0} $\n", "\n", "$D_\\alpha \\, X \\, \\tilde{D_\\alpha} $" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "D = lambda alpha: e**((-log(alpha)/2.)&(E0)) \n", "alpha = rand()\n", "assert(down( D(alpha)&up(a)&~D(alpha)) == (alpha&a))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Versers partly in $E_0$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Translations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$ V = e ^{\\frac{1}{2} e_{\\infty} a } = 1 + e_{\\infty}a$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "T = lambda x: e**(1/2.&(einf&x)) \n", "assert(down( T(a)&up(b)&~T(a)) == b+a)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Transversions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A transversion is an inversion, followed by a translation, followed by a inversion. The verser is \n", "\n", "$$V= e_+ T_a e_+$$\n", "\n", "which is recognised as the translation bivector reflected in the $e_+$ vector. From the diagram, it is seen that this is equivalent to the bivector in $x\\wedge e_o$,\n", "\n", "$$ e_+ (1+e_{\\infty}a)e_+ $$\n", "\n", "$$ e_+^2 + e_+e_{\\infty}a e_+$$\n", "$$2 +2e_o a$$\n", "\n", "the factor of 2 may be dropped, because the conformal vectors are null\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "V = e2 & T(a) & e2\n", "assert ( V == 1+(eo&a))\n", "\n", "K = lambda x: 1+(eo&a) \n", "\n", "B= up(b)\n", "assert( down(K(a) & B & ~K(a)) == 1/(a+1/b) ) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Versers Out of $E_0$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Versers that are out of $E_0$ are made up of the versers within the original space. These include reflections and rotations, and their conformal representation is identical to their form in $G^n$, except the minus sign is dropped for reflections, " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reflections" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$ -mam \\rightarrow MA\\tilde{M} $$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "m = v2()\n", "m = m/abs(m)\n", "assert(down(m&up(a)&m) == -m&a&m)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Rotations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$ mnanm = Ra\\tilde{R} \\rightarrow RA\\tilde{R} $$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "R = lambda theta: e**((-.5*theta)&(e0^e1))\n", "theta = pi/2\n", "assert(down( R(theta)&up(a)&~R(theta)) == R(theta)&a&~R(theta))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Combinations of Operations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### simple example" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As a simple example consider the combination operations of translation,scaling, and inversion. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$b=-2a+e_0 \\quad \\rightarrow \\quad B= (T_{e_0}E_0 D_2) A \\tilde{ (D_2 E_0 T_{e_0})} $$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "A = up(a)\n", "V = T(e0)&E0&D(2)\n", "B = V&A&~V\n", "assert(down(B) == (-2&a)+e0 )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Transversion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A transversion may be built from a inversion, translation, and inversion. \n", "\n", "$$c = (a^{-1}+b)^{-1}$$\n", "\n", "In conformal GA, this is accomplished by \n", "\n", "$$C = VA\\tilde{V}$$\n", "\n", "$$V= e_+ T_b e_+$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "A = up(a)\n", "V = e2&T(b)&e2\n", "C = V&A&~V\n", "assert(down(C) ==1/(1/a +b))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Rotation about a point " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Rotation about a point, $a$ can be achieved by translating the origina to $a$ then rotating, then translating back. Just like the transversion can be thought of as translating the involution operator, rotation about a point can also be thought of as translating the Rotor itself. Covariance. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "r = R(pi/2.)\n", "\n", "Q =T(a)&r&~T(a)\n", "\n", "B= up(b)\n", "C=Q&B&~Q\n", "c=down(C)\n", "\n", "c" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Interpreting Complex Numbers " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The incorperation of complex number can be done in a number of ways. One way is to translate the complex numbers to 2D vectors.\n", "This is done first by identifying the complex numbers with the even grade elements in $G^2$, which are spinors. \n", "\n", "$$\n", "\\mathbb{C}\\Longrightarrow G^{2+} \\Longrightarrow G^{2-}\\\\\n", "\\mathbf{a}\\Longrightarrow A\\Longrightarrow a\n", "$$\n", "\n", "\n", "All spinors in $G^2$ can be expressed as the product of a chosen 'real' vector, such as $e_0$, and another vector,\n", "\n", "\n", "\\begin{eqnarray*}\n", "A & = & e_{0}a\\\\\n", "\\tilde{A} & = & ae_{0}\\\\\n", "A^{-1} = \\frac{\\tilde{A}}{\\tilde{A}A}& = & a^{-1}e_{0}\n", "\\end{eqnarray*}\n", "\n", "Left multiplying a spinor by $e_0$ converts them into vectors.\n", "\\begin{eqnarray*}\n", "A & \\rightarrow & a\\\\\n", "\\tilde{A} & \\rightarrow & e_{0}ae_{0}\\\\\n", "A^{-1} & \\rightarrow & e_{0}a^{-1}e_{0}\\\\\n", "AB=BA & \\rightarrow & ae_{0}b=be_{0}a\n", "\\end{eqnarray*}\n", "\n", "Note the order of translation is important, for operations to be transformed properly. For example, given the product $\\mathbf{ab}$, one is tempted to write $\\mathbf{ab}=ab$, which would be wrong. First, $\\mathbf{a}$ and $\\mathbf{b}$ must be translated to spinors $A$ and $B$, then converted to vectors. \n", "$$\n", "AB = e_0ae_0b \\rightarrow e_0^2 a e_0 b = a e_0 b\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Circuit Representation Transform: Impedance and Scattering " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Starting with the transform \n", "$$\n", "s = \\frac{\\mathbf{z}-1}{\\mathbf{z}+1}\n", "$$\n", "\n", "where $\\mathbf{z}$ is a complex number. This can be rewritten as a series of operations as such, \n", "\n", "\\begin{eqnarray*}\n", "-2(\\mathbf{z}+1)^{-1}+1\n", "\\end{eqnarray*}\n", "\n", "then expression can be converted into one containing vectors.\n", "\n", "\\begin{eqnarray*}\n", "-2e_0(z+e_0)^{-1}+e_0\n", "\\end{eqnarray*}\n", "\n", "where $z= e_0 Z$\n", "\n", "The verser representation is \n", "\n", "$$V = T_{e_0} E_0 D_2 e_0 e_+ T_{e_0} $$\n", " \n", "[This can probaly be simplified]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Complex Representation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "z = v2()\n", "\n", "z_ = v2c(z)\n", "(z_-1)/(z_+1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Vector Representation in GA" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "(-2 & e0 & (z+e0).inv() & e0) + e0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Verser Representation in CGA" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Z = up(z)\n", "Q = T(e0) & D(2)&e0 & e2 & T(e0)\n", "S = -Q&Z&~Q\n", "s = down(S)\n", "\n", "s" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Q = T(e0) & D(2)&e0 & e2 & T(e0)\n", "theta = arccos(float(Q(0))) \n", "\n", "R = e**((theta)&(Q(2)/abs(Q(2))))\n", "theta/pi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Embedding a network " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$\\mathbf{m} = \\mathbf{s_{00}}+ \\mathbf{s_{01}}(\\mathbf{a}^{-1}-\\mathbf{s_{11}})^{-1}$\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s11_, s00_, s01_, a_= rf.rand_c(4)\n", "s11,s00,s01,a = map(c2v,(s11_, s00_, s01_,a_))\n", "\n", "#assert( ((e01&((e0&a.inv()&e0)-e11).inv())&e0)+ (e00) ==\\\n", "# c2v(e00_ + e01_/(1/a_ -e11_)))\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Scratch" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "a,b,c,d = [v2() for k in range(4)]\n", "A,B,C,D = map(up, (a,b,c,d))\n", "\n", "d= a&b&c\n", "d\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "e01 = e0^e1\n", "c2s = lambda c: c.real + (c.imag&e01) # complex to G2 Spinor" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n", "c_ =rand()+rand()*1j\n", "c = c2s(c_)\n", "c" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "assert(down(up(c)) == c)\n", "C = up(C)\n", "C" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "down(T(e0) & C & ~T(e0))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "e0&a.inv()&e0 == (e0&a&e0).inv()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n", "(a.inv()&b.inv()) - (a&b).inv()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "IPython (Python 2)", "language": "python", "name": "python2" }, "language_info": { "name": "python", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }