{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Examples of first-order tensor manipulation\n",
"\n",
"First we define a 4D manifold with Minkowski metric"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%display latex"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ 1 0 0 0]\n",
"[ 0 -1 0 0]\n",
"[ 0 0 -1 0]\n",
"[ 0 0 0 -1]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"M = Manifold(4, 'M', structure='Lorentzian')\n",
"C. = M.chart()\n",
"g = M.metric()\n",
"g[0, 0], g[1, 1], g[2, 2], g[3, 3] = 1, -1, -1, -1\n",
"g[:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's perturbate this metric with a small tensor $h$, depending on a small parameter $\\tau$."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ 1 e^(-tau*x) 2*e^(-2*tau*y) 3*e^(-3*tau*z)]\n",
"[ e^(-tau*x) -1 0 0]\n",
"[2*e^(-2*tau*y) 0 -1 0]\n",
"[3*e^(-3*tau*z) 0 0 -1]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tau = var('tau')\n",
"h = M.tensor_field(0, 2, sym=(0,1))\n",
"h[0, 1], h[0, 2], h[0, 3] = exp(-tau*x), 2*exp(-2*tau*y), 3*exp(-3*tau*z)\n",
"g.set(g + h)\n",
"g[:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The computation of the connection takes several seconds, and produces big expressions."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"Gam^t_xx = -tau*e^(tau*x + 4*tau*y + 6*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^t_yy = -4*tau*e^(2*tau*x + 2*tau*y + 6*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^t_zz = -9*tau*e^(2*tau*x + 4*tau*y + 3*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^x_xx = -tau*e^(4*tau*y + 6*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^x_yy = -4*tau*e^(tau*x + 2*tau*y + 6*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^x_zz = -9*tau*e^(tau*x + 4*tau*y + 3*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^y_xx = -2*tau*e^(tau*x + 2*tau*y + 6*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^y_yy = -8*tau*e^(2*tau*x + 6*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^y_zz = -18*tau*e^(2*tau*x + 2*tau*y + 3*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^z_xx = -3*tau*e^(tau*x + 4*tau*y + 3*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^z_yy = -12*tau*e^(2*tau*x + 2*tau*y + 3*tau*z)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) \n",
"Gam^z_zz = -27*tau*e^(2*tau*x + 4*tau*y)/(((e^(2*tau*x) + 1)*e^(4*tau*y) + 4*e^(2*tau*x))*e^(6*tau*z) + 9*e^(2*tau*x + 4*tau*y)) "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nab = g.connection()\n",
"nab.display(only_nonredundant=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If $\\tau$ is small, it can be interesting to look a this at the first order. It appears for example that it is completely independent of the coordinates."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"Gam^t_xx = -1/15*tau \n",
"Gam^t_yy = -4/15*tau \n",
"Gam^t_zz = -3/5*tau \n",
"Gam^x_xx = -1/15*tau \n",
"Gam^x_yy = -4/15*tau \n",
"Gam^x_zz = -3/5*tau \n",
"Gam^y_xx = -2/15*tau \n",
"Gam^y_yy = -8/15*tau \n",
"Gam^y_zz = -6/5*tau \n",
"Gam^z_xx = -1/5*tau \n",
"Gam^z_yy = -4/5*tau \n",
"Gam^z_zz = -9/5*tau "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nab.set_calc_order(tau, 1, True)\n",
"nab.display(only_nonredundant=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is also possible to perform the computation of the connection completely at the first order, by setting the order of $g$ instead of $\\Gamma$. All derived quatities are then computed at this order."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ 1 -tau*x + 1 -4*tau*y + 2 -9*tau*z + 3]\n",
"[ -tau*x + 1 -1 0 0]\n",
"[-4*tau*y + 2 0 -1 0]\n",
"[-9*tau*z + 3 0 0 -1]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g.set_calc_order(tau, 1, True)\n",
"g[:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The computation of the connection is much faster, and of course gives the same result."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"True"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nab2 = g.connection()\n",
"nab == nab2"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 8.7.beta7",
"language": "",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}