Skip to content

Instantly share code, notes, and snippets.

@arsenovic
Created January 4, 2021 12:52
Show Gist options
  • Save arsenovic/679dd826a464429ed5b84ede66b24580 to your computer and use it in GitHub Desktop.
Save arsenovic/679dd826a464429ed5b84ede66b24580 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## vector functions of a scalar variable\n",
"lets say we have a $N$-d vector-valued function of a scalar variable, $f(t)= f_t$.\n",
"we add a dimension, $e_0$, which we interpret as values of independent variable $t$. the function is now \n",
"$r = f_t + te_0 $. \n",
"Given a discrete set of $t$-values, $r$ is just a list of vectors. we take the `diff` of $r$ to compute the vector differential, $\\dot {r}$, which is also just a list of vectors. \n",
"\n",
"the derivative of $f_t$ with respect to $t$ is now computed by the split of $r$ with the new dimension, \n",
"$V= \\frac{r\\wedge e_0}{r\\cdot e_0}$. change in velocity we guess is \n",
"\n",
"$A_1 = V_2/V_1$ and so on for many indecies , which is like a diff but with division between sequential velocities.\n",
"\n",
"There is also $\\Omega = \\dot{r}\\wedge \\ddot{r}$"
]
},
{
"cell_type": "code",
"execution_count": 101,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([(1.0^e1), (0.6732^e0) + (1.45503^e1) - (0.62349^e2),\n",
" (1.3464^e0) + (1.56892^e1) - (0.97493^e2),\n",
" (2.0196^e0) + (1.58571^e1) - (0.90097^e2),\n",
" (2.69279^e0) + (1.79182^e1) - (0.43388^e2),\n",
" (3.36599^e0) + (2.39106^e1) + (0.22252^e2),\n",
" (4.03919^e0) + (3.4157^e1) + (0.78183^e2),\n",
" (4.71239^e0) + (4.71239^e1) + (1.0^e2),\n",
" (5.38559^e0) + (6.00908^e1) + (0.78183^e2),\n",
" (6.05879^e0) + (7.03371^e1) + (0.22252^e2),\n",
" (6.73198^e0) + (7.63295^e1) - (0.43388^e2),\n",
" (7.40518^e0) + (7.83907^e1) - (0.90097^e2),\n",
" (8.07838^e0) + (7.85586^e1) - (0.97493^e2),\n",
" (8.75158^e0) + (7.96975^e1) - (0.62349^e2),\n",
" (9.42478^e0) + (8.42478^e1)], dtype=object)"
]
},
"execution_count": 101,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from clifford import Cl,MVArray\n",
"from clifford.tools import mat2Frame, frame2Mat\n",
"from pylab import * \n",
"\n",
"\n",
"\n",
"l,b = Cl(sig=[-1,1,1],firstIdx=0)\n",
"locals().update(b)\n",
"\n",
"I_ = l.pseudoScalar\n",
"I = e12#I_/e0\n",
"split = lambda x: (x^e0)/(x|e0)\n",
"div = lambda x: [x[k+1]/x[k] for k in range(len(x)-1)] # like diff but division \n",
"\n",
"\n",
"t = linspace(0,3*pi,15)\n",
"f = t*e1+ e**(t*e12)*e1 # function \n",
"r = t*e0 + f\n",
"r"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([0.2799635198779851, 0.293391900633451, 0.2936481833541586,\n",
" 0.25568389418796583, 0.166027328634858, 0.40672702619797746,\n",
" 0.48356779786884124, 0.4067270261978369, 0.16602732863455358,\n",
" 0.2556838941880583, 0.29364818335415194, 0.29339190063362774,\n",
" 0.2799635198779439], dtype=object)"
]
},
"execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rd = diff(r)\n",
"rdd = diff(rd)\n",
"V = MVArray(list(map(split,rd)))\n",
"A = MVArray(div(V))\n",
"omega = MVArray([k^l for k,l in zip(rd,rdd)])\n",
"abs(omega)"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([(0.6732^e0) + (0.45503^e1) - (0.62349^e2),\n",
" (0.6732^e0) + (0.11389^e1) - (0.35144^e2),\n",
" (0.6732^e0) + (0.01679^e1) + (0.07396^e2),\n",
" (0.6732^e0) + (0.20611^e1) + (0.46709^e2),\n",
" (0.6732^e0) + (0.59924^e1) + (0.6564^e2),\n",
" (0.6732^e0) + (1.02464^e1) + (0.55931^e2),\n",
" (0.6732^e0) + (1.29669^e1) + (0.21817^e2),\n",
" (0.6732^e0) + (1.29669^e1) - (0.21817^e2),\n",
" (0.6732^e0) + (1.02464^e1) - (0.55931^e2),\n",
" (0.6732^e0) + (0.59924^e1) - (0.6564^e2),\n",
" (0.6732^e0) + (0.20611^e1) - (0.46709^e2),\n",
" (0.6732^e0) + (0.01679^e1) - (0.07396^e2),\n",
" (0.6732^e0) + (0.11389^e1) + (0.35144^e2),\n",
" (0.6732^e0) + (0.45503^e1) + (0.62349^e2)], dtype=object)"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rd"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([-(0.34114^e1) + (0.27205^e2), -(0.09709^e1) + (0.4254^e2),\n",
" (0.18932^e1) + (0.39313^e2), (0.39313^e1) + (0.18932^e2),\n",
" (0.4254^e1) - (0.09709^e2), (0.27205^e1) - (0.34114^e2),\n",
" -(0.43634^e2), -(0.27205^e1) - (0.34114^e2),\n",
" -(0.4254^e1) - (0.09709^e2), -(0.39313^e1) + (0.18932^e2),\n",
" -(0.18932^e1) + (0.39313^e2), (0.09709^e1) + (0.4254^e2),\n",
" (0.34114^e1) + (0.27205^e2)], dtype=object)"
]
},
"execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rdd"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([(0.67592^e01) - (0.92616^e02), (0.16917^e01) - (0.52204^e02),\n",
" (0.02495^e01) + (0.10986^e02), (0.30617^e01) + (0.69383^e02),\n",
" (0.89014^e01) + (0.97505^e02), (1.52204^e01) + (0.83083^e02),\n",
" (1.92616^e01) + (0.32408^e02), (1.92616^e01) - (0.32408^e02),\n",
" (1.52204^e01) - (0.83083^e02), (0.89014^e01) - (0.97505^e02),\n",
" (0.30617^e01) - (0.69383^e02), (0.02495^e01) - (0.10986^e02),\n",
" (0.16917^e01) + (0.52204^e02), (0.67592^e01) + (0.92616^e02)],\n",
" dtype=object)"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"V"
]
},
{
"cell_type": "code",
"execution_count": 112,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([0.45476 + (0.14922^e12), -0.17643 - (0.10496^e12),\n",
" 6.60758 + (1.28649^e12), 1.65013 + (0.55477^e12),\n",
" 1.24202 + (0.42713^e12), 1.06454 + (0.36817^e12),\n",
" 0.94494 + (0.32724^e12), 0.83902 + (0.29017^e12),\n",
" 0.71999 + (0.24761^e12), 0.54447 + (0.18305^e12),\n",
" 0.14581 + (0.02839^e12), -4.18629 - (2.49045^e12),\n",
" 1.98521 + (0.65143^e12)], dtype=object)"
]
},
"execution_count": 112,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([-(0.22966^e01) + (0.18314^e02) - (0.08891^e12),\n",
" -(0.06536^e01) + (0.28638^e02) + (0.01433^e12),\n",
" (0.12745^e01) + (0.26465^e02) - (0.0074^e12),\n",
" (0.26465^e01) + (0.12745^e02) - (0.1446^e12),\n",
" (0.28638^e01) - (0.06536^e02) - (0.33742^e12),\n",
" (0.18314^e01) - (0.22966^e02) - (0.50171^e12),\n",
" -(0.29374^e02) - (0.56579^e12),\n",
" -(0.18314^e01) - (0.22966^e02) - (0.50171^e12),\n",
" -(0.28638^e01) - (0.06536^e02) - (0.33742^e12),\n",
" -(0.26465^e01) + (0.12745^e02) - (0.1446^e12),\n",
" -(0.12745^e01) + (0.26465^e02) - (0.0074^e12),\n",
" (0.06536^e01) + (0.28638^e02) + (0.01433^e12),\n",
" (0.22966^e01) + (0.18314^e02) - (0.08891^e12)], dtype=object)"
]
},
"execution_count": 113,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"omega"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MVArray([(0.18871^e01) + (0.23664^e02), -(0.04754^e01) - (0.01085^e02),\n",
" (0.0227^e01) - (0.01093^e02), (0.21359^e01) - (0.44353^e02),\n",
" -(0.25561^e01) - (1.11988^e02), -(1.33536^e01) - (1.06492^e02),\n",
" -(1.92616^e01), -(1.33536^e01) + (1.06492^e02),\n",
" -(0.25561^e01) + (1.11988^e02), (0.21359^e01) + (0.44353^e02),\n",
" (0.0227^e01) + (0.01093^e02), -(0.04754^e01) + (0.01085^e02),\n",
" (0.18871^e01) - (0.23664^e02)], dtype=object)"
]
},
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"split(omega)`-lqz"
]
},
{
"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.7.3"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"toc_cell": false,
"toc_position": {},
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment