{
	"cell_id": 15268771084326197047,
	"cells": [
		{
			"cell_id": 17635366168350014876,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 7159893924636242532,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\package{cdb.core.manip}{Manipulating equations, inequalities and similar expressions}\n\nThis package contains various helper functions to manipulate expressions in elementary ways, e.g.~moving terms\naround or multiplying sides of an expression by a factor. In order to use this package, import it with the standard\nPython import statement: if you do \\verb|import cdb.core.manip as manip| then e.g.~the \\verb|isolate| function is available as\n\\verb|manip.isolate|."
				}
			],
			"hidden": true,
			"source": "\\package{cdb.core.manip}{Manipulating equations, inequalities and similar expressions}\n\nThis package contains various helper functions to manipulate expressions in elementary ways, e.g.~moving terms\naround or multiplying sides of an expression by a factor. In order to use this package, import it with the standard\nPython import statement: if you do \\verb|import cdb.core.manip as manip| then e.g.~the \\verb|isolate| function is available as\n\\verb|manip.isolate|."
		},
		{
			"cell_id": 219606435123158463,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "from cdb.utils.node import nth_arg, n_args"
		},
		{
			"cell_id": 7835392520042021345,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 3764403960157589060,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{eq_to_subrule(ex: Ex) -> Ex}{Create substitution rule from an equation.}"
				}
			],
			"hidden": true,
			"source": "\\algorithm{eq_to_subrule(ex: Ex) -> Ex}{Create substitution rule from an equation.}"
		},
		{
			"cell_id": 9954784203102623338,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def eq_to_subrule(ex):\n\t\"\"\"Turns $a = b$ into $b -> a$\"\"\"\n\tif ex.head() != r'\\equals':\n\t\traise Exception(\"eq_to_subrule called on expression which is not an equation\")\n\tif n_args(ex.top()) != 2:\n\t\traise Exception(\"eq_to_subrule called on expression whose top node contains {} arguments, 2 required\".format(n_args(ex.top())))\n\n\t# Get the lhs and rhs\n\tfor i, arg in enumerate(ex.top().args()):\n\t\tif i == 0:\n\t\t\tlhs = $@(arg)$\n\t\telif i == 1:\n\t\t\trhs = $@(arg)$\n\n\t# Substitute them into a subrule\n\treturn $@(rhs) -> @(lhs)$"
		},
		{
			"cell_id": 9634307933222533368,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 6645472134591897231,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "Creates a substitution rule from an equation \\verb|Ex|."
				}
			],
			"hidden": true,
			"source": "Creates a substitution rule from an equation \\verb|Ex|."
		},
		{
			"cell_id": 9556965808134248954,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 1231767427432608563,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 2956203403061753577,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "b + c + d -> a"
						}
					],
					"source": "\\begin{dmath*}{}b+c+d \\rightarrow a\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "eq_to_subrule($a = b + c + d$);"
		},
		{
			"cell_id": 7756973939992329781,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 12564986469045592293,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{multiply_through(ex: Ex, factor: Ex, auto_distribute=False) -> Ex}{Multiply all terms by the same factor.}"
				}
			],
			"hidden": true,
			"source": "\\algorithm{multiply_through(ex: Ex, factor: Ex, auto_distribute=False) -> Ex}{Multiply all terms by the same factor.}"
		},
		{
			"cell_id": 1501528717858725061,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def multiply_through(ex, factor, auto_distribute = False):\n\t\"\"\"Multiplies all terms in ex by factor\"\"\"\n\tfor arg in ex.top().args():\n\t\targ.replace($@(factor) @(arg)$)\n\tif auto_distribute:\n\t\tdistribute(ex)\n\treturn ex"
		},
		{
			"cell_id": 6901152875545504437,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 3831153165854597002,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "Multiplies all terms in \\verb|ex| by \\verb|factor|. If \\verb|auto_distribute| is \\verb|True|, distribute is called on the resulting expression."
				}
			],
			"hidden": true,
			"source": "Multiplies all terms in \\verb|ex| by \\verb|factor|. If \\verb|auto_distribute| is \\verb|True|, distribute is called on the resulting expression."
		},
		{
			"cell_id": 9575833646660580740,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 2887283422742923798,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 5607098118281175915,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "k (a + b) < k c"
						}
					],
					"source": "\\begin{dmath*}{}k \\left(a+b\\right) < k c\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "multiply_through($a+b < c$, $k$);"
		},
		{
			"cell_id": 3396515398006428816,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 3396515398006428816,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{add_through(ex: Ex, factor: Ex) -> Ex}{Add a factor to both sides of an equation.}"
				}
			],
			"hidden": true,
			"source": "\\algorithm{add_through(ex: Ex, factor: Ex) -> Ex}{Add a factor to both sides of an equation.}"
		},
		{
			"cell_id": 544175776537438149,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def add_through(ex, factor):\n\t\"\"\"Adds a factor to both sides of ex\"\"\"\n\tfor arg in ex.top().args():\n\t\targ.replace($@(arg) + @(factor)$)\n\treturn ex"
		},
		{
			"cell_id": 16915415318035386515,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 9720663929603140956,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 10454479142087391198,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "A_{\\mu} B_{\\nu} + D_{\\mu \\nu} = C_{\\mu \\nu} + D_{\\mu \\nu}"
						}
					],
					"source": "\\begin{dmath*}{}A_{\\mu} B_{\\nu}+D_{\\mu \\nu} = C_{\\mu \\nu}+D_{\\mu \\nu}\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "add_through($A_{\\mu}B_{\\nu} = C_{\\mu \\nu}$, $D_{\\mu \\nu}$);"
		},
		{
			"cell_id": 13652224870070875183,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 18204803698960052673,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{apply_through(ex: Ex, op: Ex) -> Ex}{Apply an operator through both sides of an equation.}"
				}
			],
			"hidden": true,
			"source": "\\algorithm{apply_through(ex: Ex, op: Ex) -> Ex}{Apply an operator through both sides of an equation.}"
		},
		{
			"cell_id": 7129671199504928557,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def apply_through(ex, op):\n\tfor child in ex.top().children():\n\t\tapp := @(op);\n\t\tfor node in app[\"#\"]:\n\t\t\tnode.replace($@(child)$)\n\t\tchild.replace($@(app)$)\n\treturn ex"
		},
		{
			"cell_id": 1222096101185570042,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 17643016095692415648,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 17377967479870284885,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "\\partial(\\partial(x_{\\mu})) = \\partial(0)"
						}
					],
					"source": "\\begin{dmath*}{}\\partial\\left(\\partial\\left(x_{\\mu}\\right)\\right) = \\partial\\left(0\\right)\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "apply_through($\\partial{x_{\\mu}} = 0$, $\\partial{#}$);"
		},
		{
			"cell_id": 3411326601020319930,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 2419666349840739992,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{get_lhs(ex: Ex) -> Ex}{Return left-hand side of an expression}\n\nReturns the left hand side of an equation, inequality or expression whose top node contains two children. "
				}
			],
			"hidden": true,
			"source": "\\algorithm{get_lhs(ex: Ex) -> Ex}{Return left-hand side of an expression}\n\nReturns the left hand side of an equation, inequality or expression whose top node contains two children. "
		},
		{
			"cell_id": 5307119722135943631,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def get_lhs(ex):\n\t\"\"\"Returns the left hand side of an equation, inequality, or expression whose top node contains two arguments\"\"\"\n\tif isinstance(ex, Ex):\n\t\tex = ex.top()\n\tif n_args(ex) != 2:\n\t\traise Exception(\"get_lhs called on expression whose top node contains {} arguments, 2 required\".format(n_args(ex)))\n\treturn nth_arg(ex, 0).ex()"
		},
		{
			"cell_id": 5233847834690152710,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 3168203333233232823,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 8343678120098024622,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "a"
						}
					],
					"source": "\\begin{dmath*}{}a\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "get_lhs($a=b$);"
		},
		{
			"cell_id": 9795365978364924824,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 14660442160948713050,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{get_rhs(ex: Ex) -> Ex}{Return right-hand side of an expression}\n\nReturns the right-hand side of an equation, inequality or expression whose top node contains two children. "
				}
			],
			"hidden": true,
			"source": "\\algorithm{get_rhs(ex: Ex) -> Ex}{Return right-hand side of an expression}\n\nReturns the right-hand side of an equation, inequality or expression whose top node contains two children. "
		},
		{
			"cell_id": 11895343331560033174,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def get_rhs(ex):\n\t\"\"\"Returns the right hand side of an equation, inequality, or expression whose top node contains two arguments\"\"\"\n\tif isinstance(ex, Ex):\n\t\tex = ex.top()\n\tif n_args(ex) != 2:\n\t\traise Exception(\"get_rhs called on expression whose top node contains {} arguments, 2 required\".format(n_args(ex)))\n\treturn nth_arg(ex, 1).ex()"
		},
		{
			"cell_id": 8733667829887500319,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 11709535240682201585,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 13877803436156210079,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "b"
						}
					],
					"source": "\\begin{dmath*}{}b\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "get_rhs($a=b$);"
		},
		{
			"cell_id": 11158988917891525944,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 5905171491089882952,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{swap_sides(ex: Ex) -> Ex}{Swap the left and right-hand sides of an expression.}\n\n\tSwaps the two sides of an equation, inequality or expression whose top node contains two children. Inequalities will flip as appropriate. \n"
				}
			],
			"hidden": true,
			"source": "\\algorithm{swap_sides(ex: Ex) -> Ex}{Swap the left and right-hand sides of an expression.}\n\n\tSwaps the two sides of an equation, inequality or expression whose top node contains two children. Inequalities will flip as appropriate. \n"
		},
		{
			"cell_id": 8794265449613865573,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def swap_sides(ex):\n\t\"\"\"Swaps the left and right hand sides of an equation, inequality or expression whose top node contains two arguments\"\"\"\n\tif n_args(ex.top()) != 2:\n\t\traise Exception(\"swap_sides called on expression whose top node contains {} arguments, 2 required\".format(n_args(ex.top())))\n\n\t# Get the lhs and rhs\n\tlhs = get_lhs(ex)\n\trhs = get_rhs(ex)\n\n\t# Iterate through both sides of the equation and perform substitution\n\tfor i, arg in enumerate(ex.top().args()):\n\t\tif i == 0:\n\t\t\targ.replace(rhs)\n\t\tif i == 1:\n\t\t\targ.replace(lhs)\n\n\t# Swap inequalities\n\tif ex.head() == r'\\less':\n\t\tex.top().name = r'\\greater'\n\telif ex.head() == r'\\greater':\n\t\tex.top().name = r'\\less'\n\n\treturn ex"
		},
		{
			"cell_id": 8255195960622299062,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 14853923507974116134,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{get_factor(node: ExNode, term: Ex) -> Ex}{Get all multiplicative factors of term in node}"
				}
			],
			"hidden": true,
			"source": "\\algorithm{get_factor(node: ExNode, term: Ex) -> Ex}{Get all multiplicative factors of term in node}"
		},
		{
			"cell_id": 12899144978785485126,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def get_factor(node, term):\n\t\"\"\"If node is a product containing term, then return node without term. Otherwise, return None\"\"\"\n\tif term.matches(node):\n\t\treturn substitute($@(node)$, $@(term) -> 1$)\n\n\tif node.name == r'\\prod':\n\t\tret = $@(node)$\n\t\tfor elem in ret.top().children():\n\t\t\tif term.matches(elem):\n\t\t\t\tfactor = elem.multiplier\n\t\t\t\telem.erase()\n\t\t\t\tret.top().multiplier *= factor\n\t\t\t\treturn ret\n\n\treturn None"
		},
		{
			"cell_id": 6640730744419052590,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 2447757695444069929,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 11353889507680660796,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": " 3/2 "
						}
					],
					"source": "\\begin{dmath*}{}\\frac{3}{2}\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "get_factor($3/2 R$.top(), $R$);"
		},
		{
			"cell_id": 16431542648255979031,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 30848241778554462,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{get_basis_component(ex: Ex, basis: Ex) -> Ex}{Returns the multiplicative coefficients of \\texttt{basis} in \\texttt{ex}}"
				}
			],
			"source": "\\algorithm{get_basis_component(ex: Ex, basis: Ex) -> Ex}{Returns the multiplicative coefficients of \\texttt{basis} in \\texttt{ex}}"
		},
		{
			"cell_id": 13837484073210088531,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def get_basis_component(ex, basis):\n\tcoeff = take_match($@(ex)$, $@(basis) Q??$)\n\tsubstitute(coeff, $@(basis) -> 1$)\n\tif ex == coeff:\n\t\treturn $0$\n\telse:\n\t\treturn $@(coeff)$"
		},
		{
			"cell_id": 9594057414621049635,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 16102671816984278626,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 16215812578025033456,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "A_{\\mu \\nu} \\exp(i k_{\\mu} x^{\\mu}) + B_{\\mu \\nu} \\exp(-i k_{\\mu} x^{\\mu})"
						}
					],
					"source": "\\begin{dmath*}{}A_{\\mu \\nu} \\exp\\left(i k_{\\mu} x^{\\mu}\\right)+B_{\\mu \\nu} \\exp\\left(-i k_{\\mu} x^{\\mu}\\right)\\end{dmath*}"
				},
				{
					"cell_id": 3121979421771299112,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 5653504327284017440,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "B_{\\mu \\nu}"
						}
					],
					"source": "\\begin{dmath*}{}B_{\\mu \\nu}\\end{dmath*}"
				},
				{
					"cell_id": 724265581768911366,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 17952817033461765105,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "\\exp(i k_{\\mu} x^{\\mu})"
						}
					],
					"source": "\\begin{dmath*}{}\\exp\\left(i k_{\\mu} x^{\\mu}\\right)\\end{dmath*}"
				},
				{
					"cell_id": 11823143836272174168,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 2203812047172188274,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "A_{\\mu \\nu} \\exp(i x^{\\mu}) + B_{\\mu \\nu} \\exp(-i x^{\\mu})"
						}
					],
					"source": "\\begin{dmath*}{}A_{\\mu \\nu} \\exp\\left(i x^{\\mu}\\right)+B_{\\mu \\nu} \\exp\\left(-i x^{\\mu}\\right)\\end{dmath*}"
				},
				{
					"cell_id": 2563792950653075125,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 2527418973058329912,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "0"
						}
					],
					"source": "\\begin{dmath*}{}0\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "test := A_{\\mu\\nu} \\exp(i*k_\\mu*x^{\\mu})+B_{\\mu\\nu} \\exp(-i*k_\\mu*x^{\\mu});\nget_basis_component(test, $\\exp(-i*k_\\mu*x^{\\mu})$);\nget_basis_component(test, $A_{\\mu\\nu}$);\nget_basis_component(test, $k_{\\mu}$);\nget_basis_component(test, $C_{\\mu\\nu}$);"
		},
		{
			"cell_id": 560186604802672427,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 4386267152773659670,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{to_rhs(ex: Ex, *parts: Ex..., match_type: str = \"all\") -> Ex}{Move the indicated term of the expression to the right-hand side.}\n\n\tIf \\verb|ex| is an equation or inequality which contains \\verb|part| on its left hand side, then moves all \\verb|parts| to the right hand side. \n\t\\verb|match_type| can be either \\verb|all| which will move all terms which contain each part as a factor, \\verb|numeric| which will move terms up to a numeric prefactor or \n     \\verb|exact| which will only move the term if the subtree matches exactly."
				}
			],
			"hidden": true,
			"source": "\\algorithm{to_rhs(ex: Ex, *parts: Ex..., match_type: str = \"all\") -> Ex}{Move the indicated term of the expression to the right-hand side.}\n\n\tIf \\verb|ex| is an equation or inequality which contains \\verb|part| on its left hand side, then moves all \\verb|parts| to the right hand side. \n\t\\verb|match_type| can be either \\verb|all| which will move all terms which contain each part as a factor, \\verb|numeric| which will move terms up to a numeric prefactor or \n     \\verb|exact| which will only move the term if the subtree matches exactly."
		},
		{
			"cell_id": 2183163939635232499,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def to_rhs(ex, *parts, match_type = \"all\"):\n\t\"\"\"Moves part from the left to the right hand side of an equation or inequality\"\"\"\n\n\tassert(ex.top().name in [r'\\equals', r'\\less', r'\\greater'])\n\tassert(n_args(ex.top()) == 2)\n\n\tif match_type == \"exact\":\n\t\tcomp = lambda ex, node: ex == $@(node)$\n\telif match_type == \"numeric\":\n\t\tcomp = lambda ex, node: ex.matches(node)\n\telif match_type == \"all\":\n\t\tcomp = lambda ex, node: get_factor(node, ex) is not None\n\n\tlhs = nth_arg(ex.top(), 0)\n\trhs = nth_arg(ex.top(), 1)\n\n\tif len(parts) == 0:\n\t\tterms = $@(rhs) - @(lhs)$\n\t\tlhs.replace($0$)\n\t\trhs.replace(terms)\n\telse:\n\t\tfor part in parts:\n\t\t\tterms = $@(rhs)$\n\t\t\tif comp(part, lhs):\n\t\t\t\tterms -= lhs\n\t\t\t\tlhs.replace($0$)\n\t\t\telif lhs.name == r'\\sum':\n\t\t\t\tfor i in reversed(range(n_args(lhs))):\n\t\t\t\t\tnode = nth_arg(lhs, i)\n\t\t\t\t\tif comp(part, node):\n\t\t\t\t\t\tterms -= node\n\t\t\t\t\t\tif n_args(lhs) == 1:\n\t\t\t\t\t\t\tnode.replace($0$)\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\tnode.erase()\n\t\t\trhs.replace(terms)\n\n\treturn ex"
		},
		{
			"cell_id": 11883098882754637540,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 13131403568144277521,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 9493999741510812343,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "0 = c + d-2a-b-j b-k b"
						}
					],
					"source": "\\begin{dmath*}{}0 = c+d-2a-b-j b-k b\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "to_rhs($2a+b+j*b+k*b = c+d$);"
		},
		{
			"cell_id": 9319840788300028258,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 15999046563881551767,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 17760236547502669845,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "-\\partial_{\\alpha}(b_{\\beta})-\\partial_{\\beta}(a_{\\alpha}) = 0"
						}
					],
					"source": "\\begin{dmath*}{}-\\partial_{\\alpha}{b_{\\beta}}-\\partial_{\\beta}{a_{\\alpha}} = 0\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "\\partial{#}::Derivative.\nto_rhs($-\\partial_{\\alpha}{b_{\\beta}} - \\partial_{\\beta}{a_{\\alpha}} = 0$, $\\partial_{\\alpha}{b_{\\beta}}$, match_type=\"exact\");"
		},
		{
			"cell_id": 831589588542616074,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 5886747838826691399,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{to_lhs(ex: Ex, *parts: Ex..., match_type: str = \"all\") -> Ex}{Move the indicated term of the expression to the left-hand side.}\n\nComplement of \\algo{to_rhs}."
				}
			],
			"hidden": true,
			"source": "\\algorithm{to_lhs(ex: Ex, *parts: Ex..., match_type: str = \"all\") -> Ex}{Move the indicated term of the expression to the left-hand side.}\n\nComplement of \\algo{to_rhs}."
		},
		{
			"cell_id": 5674786013392212620,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def to_lhs(ex, *parts, match_type=\"all\"):\n\t\"\"\"Moves part from the right to the left hand side of an equation or inequality\"\"\"\n\t# to_lhs is the same as to_rhs called on an equation with the sides swapped ;)\n\tswap_sides(ex)\n\tto_rhs(ex, *parts, match_type=match_type)\n\tswap_sides(ex)\t\n\treturn ex"
		},
		{
			"cell_id": 4956212081149797277,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 15571824009976413118,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{isolate()}{Isolates a term on the left hand side of an equation or inequality}"
				}
			],
			"hidden": true,
			"source": "\\algorithm{isolate()}{Isolates a term on the left hand side of an equation or inequality}"
		},
		{
			"cell_id": 15010735023331358315,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def isolate(ex, term, divide_through = True):\n\t\"\"\"Isolates a term on the left hand side of an equation or inequality\"\"\"\n\tassert(ex.top().name in [r'\\equals', r'\\less', r'\\greater'])\n\tassert(n_args(ex.top()) == 2)\n\n\t# Move everything to the rhs\n\tto_rhs(ex)\n\tlhs = nth_arg(ex.top(), 0)\n\trhs = nth_arg(ex.top(), 1)\n\n\t# Gather all terms containing the isolating term\n\tfactors = $0$\n\tif get_factor(rhs, term) is not None:\n\t\tfactors -= get_factor(rhs, term)\n\t\trhs.replace($0$)\n\telif rhs.name == r'\\sum':\n\t\tfor i in reversed(range(n_args(rhs))):\n\t\t\tnode = nth_arg(rhs, i)\n\t\t\tfactor = get_factor(node, term)\n\t\t\tif factor is not None:\n\t\t\t\tfactors -= factor\n\t\t\t\tif n_args(rhs) == 1:\n\t\t\t\t\tnode.replace($0$)\n\t\t\t\telse:\n\t\t\t\t\tnode.erase()\n\t# Move the isolated term over to the left hand side\n\tif divide_through:\n\t\tlhs.replace($@(term)$)\n\t\trhs.replace($\\frac{@(rhs)}{@(factors)}$)\n\telse:\n\t\tlhs.replace($@(term) @(factors)$)\n\treturn ex"
		},
		{
			"cell_id": 1368746495472243320,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 2873619635301860056,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 13925632780223323022,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "2a +  1/2 a k-b = c a + b k + a-4"
						}
					],
					"source": "\\begin{dmath*}{}2a+\\frac{1}{2}a k-b = c a+b k+a-4\\end{dmath*}"
				},
				{
					"cell_id": 3371428283246160850,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 11163140055737119195,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "a = (b k-4 + b) (1-c)**(-1)"
						}
					],
					"source": "\\begin{dmath*}{}a = \\left(b k-4+b\\right) {\\left(1-c\\right)}^{-1}\\end{dmath*}"
				},
				{
					"cell_id": 18420991104162350602,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 990642930475677695,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": " -  3/2 R + 5\\Lambda = T \\kappa"
						}
					],
					"source": "\\begin{dmath*}{} - \\frac{3}{2}R+5\\Lambda = T \\kappa\\end{dmath*}"
				},
				{
					"cell_id": 14637382425423859095,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 17517195226234096204,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "R =  -  2/3 T \\kappa +  10/3 \\Lambda"
						}
					],
					"source": "\\begin{dmath*}{}R =  - \\frac{2}{3}T \\kappa+\\frac{10}{3}\\Lambda\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "ex := 2a + 1/2 a * k - b = c * a + b * k + a - 4;\nisolate(ex, $a$, True);\nex2 := -3/2 R + 5\\Lambda = T\\kappa;\nisolate(ex2, $R$);"
		},
		{
			"cell_id": 772577804236751633,
			"cell_origin": "client",
			"cell_type": "input",
			"source": ""
		}
	],
	"description": "Cadabra JSON notebook format",
	"version": 1.0
}
