{
	"cell_id": 6806321452497212969,
	"cells": [
		{
			"cell_id": 1025456808033925757,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 9687610247019435570,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\package{cdb.sympy.calculus}{Use SymPy calculus functionality on Cadabra expressions.}\n\nA lot of functionality in SymPy can be used on Cadabra expressions, but in order to correctly\nconvert from and to the SymPy expression form, we need a bridge. This package contains such\nbridging fuctions, which will ensure that e.g. tensor indices are handled correctly when\nfed through SymPy's scalar algebra algorithms.\n\n\\algorithm{diff}{Differentiate an expression with respect to one or more variables.}\n\nThis function mimics the SymPy \\verb|diff| function, except that all expressions need\nto be Cadabra expressions. The function takes an expression and an arbitrary number\nof variables with respect to which to differentiate it."
				}
			],
			"hidden": true,
			"source": "\\package{cdb.sympy.calculus}{Use SymPy calculus functionality on Cadabra expressions.}\n\nA lot of functionality in SymPy can be used on Cadabra expressions, but in order to correctly\nconvert from and to the SymPy expression form, we need a bridge. This package contains such\nbridging fuctions, which will ensure that e.g. tensor indices are handled correctly when\nfed through SymPy's scalar algebra algorithms.\n\n\\algorithm{diff}{Differentiate an expression with respect to one or more variables.}\n\nThis function mimics the SymPy \\verb|diff| function, except that all expressions need\nto be Cadabra expressions. The function takes an expression and an arbitrary number\nof variables with respect to which to differentiate it."
		},
		{
			"cell_id": 3804610120254550473,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def diff(ex, *args):\n   ret = $@(ex)$\n   sb = SympyBridge(ret)\n   dvars = []\n   for arg in args:\n       sbtmp = SympyBridge(arg)\n       dvars.append( sbtmp.to_sympy() )\n   sb.from_sympy( str(sympy.diff( sb.to_sympy(), *dvars ) ) )\n   return ret"
		},
		{
			"cell_id": 12308609622224851480,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 13996360633394007671,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "A typical example, differentiating with respect to a single variable:"
				}
			],
			"hidden": true,
			"source": "A typical example, differentiating with respect to a single variable:"
		},
		{
			"cell_id": 1389897799554975903,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 1348085833411850626,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 16874039423838371410,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "A_{\\mu}(x) \\cos(x) + \\sin(x) \\partial_{x}(A_{\\mu}(x))"
						}
					],
					"source": "\\begin{dmath*}{}A_{\\mu}\\left(x\\right) \\cos{x}+\\sin{x} \\partial_{x}\\left(A_{\\mu}\\left(x\\right)\\right)\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "diff($\\sin(x) A_{\\mu}(x)$, $x$);"
		},
		{
			"cell_id": 549591636986061462,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 8841772239434008615,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 4066297813555277329,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "-\\sin(y) \\cos(x)"
						}
					],
					"source": "\\begin{dmath*}{}-\\sin{y} \\cos{x}\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "diff($\\sin(x)\\cos(y)$, $x$, $y$);"
		},
		{
			"cell_id": 6234003092100779795,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 10150353556520051186,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{integrate}{Integrate a definite or indefinite integral.}\n\nThis function mimics the SymPy \\verb|integrate| function, except that all\nmathematical expressions need to be Cadabra expressions. Indefinite integration\nis done by passing an argument which is just an expression, while definite\nintegration is done by passing a tuple consisting of the integration variable,\nthe starting point and the end point."
				}
			],
			"hidden": true,
			"source": "\\algorithm{integrate}{Integrate a definite or indefinite integral.}\n\nThis function mimics the SymPy \\verb|integrate| function, except that all\nmathematical expressions need to be Cadabra expressions. Indefinite integration\nis done by passing an argument which is just an expression, while definite\nintegration is done by passing a tuple consisting of the integration variable,\nthe starting point and the end point."
		},
		{
			"cell_id": 15467993639628642890,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def integrate(ex1, *args):\n   ret = $@(ex1)$\n   sb = SympyBridge(ret)\n   iranges = []\n   for arg in args:\n      if isinstance(arg, tuple):\n          # print(arg)\n          tmp0 = SympyBridge(arg[0]).to_sympy()\n          tmp1 = SympyBridge(arg[1]).to_sympy() if isinstance(arg[1], Ex) else arg[1]\n          tmp2 = SympyBridge(arg[2]).to_sympy() if isinstance(arg[2], Ex) else arg[2]\n          tpl = ( tmp0, tmp1, tmp2 )\n          iranges.append(tpl)\n      else:\n         tmp = SympyBridge(arg).to_sympy()\n         iranges.append( tmp )\n      \n   # print(sb.to_sympy())\n   # print(iranges)\n   sb.from_sympy( str(sympy.integrate( sb.to_sympy(), *iranges) ) )\n   return ret"
		},
		{
			"cell_id": 3801120048138997797,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 13060402605556641930,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "The following is an example of a definite integration:"
				}
			],
			"hidden": true,
			"source": "The following is an example of a definite integration:"
		},
		{
			"cell_id": 14525293143474443676,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 13720722688581652399,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 8372911878813724282,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": " 9/2 "
						}
					],
					"source": "\\begin{dmath*}{}\\frac{9}{2}\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "integrate($x**2 y$, ($x$, 0, 3), ($y$, 0, 1) );"
		},
		{
			"cell_id": 2354178610469859185,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 17727729829154494875,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "Here is an indefinite integration:"
				}
			],
			"hidden": true,
			"source": "Here is an indefinite integration:"
		},
		{
			"cell_id": 2273072162227922772,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 7232070191902961908,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 17231141432298576435,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": " 1/3 (x)**3 y"
						}
					],
					"source": "\\begin{dmath*}{}\\frac{1}{3}{x}^{3} y\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "integrate($x**2$, $x$, $y$);"
		},
		{
			"cell_id": 14437617558705092816,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 9935958107203452733,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "Mixed versions are also possible:"
				}
			],
			"hidden": true,
			"source": "Mixed versions are also possible:"
		},
		{
			"cell_id": 6556436360376410122,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 5833311602414970559,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 13975661933126978867,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": " 1/4 (y)**2"
						}
					],
					"source": "\\begin{dmath*}{}\\frac{1}{4}{y}^{2}\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "integrate($x y$, ($x$, 0, 1), $y$);"
		},
		{
			"cell_id": 15496749977354253222,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 11565454487843639642,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{limit}{Take the limit of an expression.}\n\nThis function mimics the SymPy \\verb|limit| function, except that all\nmathematical expressions need to be Cadabra expressions."
				}
			],
			"source": "\\algorithm{limit}{Take the limit of an expression.}\n\nThis function mimics the SymPy \\verb|limit| function, except that all\nmathematical expressions need to be Cadabra expressions."
		},
		{
			"cell_id": 14261374590043911759,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def limit(ex, v, loc, *args):\n   ret = $@(ex)$\n   sbex  = SympyBridge(ret)\n   sbvar = SympyBridge(v).to_sympy()\n   sbloc = SympyBridge(loc).to_sympy() if isinstance(loc, Ex) else loc\n   sbex.from_sympy( str(sympy.limit( sbex.to_sympy(), sbvar, sbloc ) ) )\n   return ret"
		},
		{
			"cell_id": 15671206733202710229,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 8723327984628819396,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 3839762579849277582,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "1"
						}
					],
					"source": "\\begin{dmath*}{}1\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "limit($\\sin(x)/x$, $x$, 0);"
		},
		{
			"cell_id": 4403018984250840411,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 11512538112824887976,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{series}{Construct a Taylor series.}\n\nThis function mimics the SymPy \\verb|series| function, except that all\nmathematical expressions need to be Cadabra expressions."
				}
			],
			"hidden": true,
			"source": "\\algorithm{series}{Construct a Taylor series.}\n\nThis function mimics the SymPy \\verb|series| function, except that all\nmathematical expressions need to be Cadabra expressions."
		},
		{
			"cell_id": 1152336426546868041,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def series(ex, v, loc, order_, *args):\n   ret = $@(ex)$\n   sbex  = SympyBridge(ret)\n   sbvar = SympyBridge(v).to_sympy()\n   sbloc = SympyBridge(loc).to_sympy() if isinstance(loc, Ex) else loc\n   tmp = str(sympy.series( sbex.to_sympy(), sbvar, sbloc, order_ ) )\n   tmp = tmp.replace(\"O(\", r\"\\bigO(\")\n   sbex.from_sympy( tmp )\n   return ret"
		},
		{
			"cell_id": 796023660136979964,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 3415134206898553614,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 17449491732516654073,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "1 -  1/6 (x)**2 + \\bigO((x)**4)"
						}
					],
					"source": "\\begin{dmath*}{}1 - \\frac{1}{6}{x}^{2}+\\bigO\\left({x}^{4}\\right)\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "q=series($\\sin(x)/x$, $x$, 0, 4);"
		},
		{
			"cell_id": 12877610158835516880,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 16889301844141721001,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 15333461881261583200,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "1 -  1/6 (x)**2"
						}
					],
					"source": "\\begin{dmath*}{}1 - \\frac{1}{6}{x}^{2}\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "substitute(q, $\\bigO(A??) ->0$);"
		},
		{
			"cell_id": 6061726248509003999,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 8301222040948595643,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 6578198996268257631,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": " 1/2 \\sqrt(2)-\\sqrt(2) ( 1/2 x -  1/8 \\pi) + \\bigO((x -  1/4 \\pi)**2 , {x,  1/4 \\pi})"
						}
					],
					"source": "\\begin{dmath*}{}\\frac{1}{2}\\sqrt{2}-\\sqrt{2} \\left(\\frac{1}{2}x - \\frac{1}{8}\\pi\\right)+\\bigO\\left({\\left(x - \\frac{1}{4}\\pi\\right)}^{2} , \\discretionary{}{}{}\\left[x,~\\discretionary{}{}{} \\frac{1}{4}\\pi\\right]\\right)\\end{dmath*}"
				}
			],
			"ignore_on_import": true,
			"source": "series($\\cos(x)$, $x$, $\\pi/4$, 2);"
		},
		{
			"cell_id": 16349293761953373413,
			"cell_origin": "client",
			"cell_type": "latex",
			"cells": [
				{
					"cell_id": 10700541688820127695,
					"cell_origin": "client",
					"cell_type": "latex_view",
					"source": "\\algorithm{factor}{Factorise an expression}\n\nThis function mimics the SymPy \\verb|factor| function, except that the argument has to be a Cadabra expression."
				}
			],
			"hidden": true,
			"source": "\\algorithm{factor}{Factorise an expression}\n\nThis function mimics the SymPy \\verb|factor| function, except that the argument has to be a Cadabra expression."
		},
		{
			"cell_id": 17538488045608728761,
			"cell_origin": "client",
			"cell_type": "input",
			"source": "def factor(ex):\n   ret = $@(ex)$\n   sbex  = SympyBridge(ret)\n   tmp = str(sympy.factor( sbex.to_sympy() ))\n   sbex.from_sympy( tmp )\n   return ret"
		},
		{
			"cell_id": 7561547917241467470,
			"cell_origin": "client",
			"cell_type": "input",
			"cells": [
				{
					"cell_id": 12368485212485632098,
					"cell_origin": "server",
					"cell_type": "latex_view",
					"cells": [
						{
							"cell_id": 1953276237970412465,
							"cell_origin": "server",
							"cell_type": "input_form",
							"source": "x (x + 1)"
						}
					],
					"source": "\\begin{dmath*}{}x \\left(x+1\\right)\\end{dmath*}"
				}
			],
			"source": "ex = factor($ x**2 + x $);"
		},
		{
			"cell_id": 16786632068897082656,
			"cell_origin": "client",
			"cell_type": "input",
			"source": ""
		}
	],
	"description": "Cadabra JSON notebook format",
	"version": 1.0
}
