|
7 | 7 | "cell_type": "latex", |
8 | 8 | "cells": [ |
9 | 9 | { |
10 | | - "cell_id": 7825517350706958358, |
| 10 | + "cell_id": 9687610247019435570, |
11 | 11 | "cell_origin": "client", |
12 | 12 | "cell_type": "latex_view", |
13 | | - "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 a variable.}" |
| 13 | + "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." |
14 | 14 | } |
15 | 15 | ], |
16 | 16 | "hidden": true, |
17 | | - "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 a variable.}" |
| 17 | + "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." |
18 | 18 | }, |
19 | 19 | { |
20 | 20 | "cell_id": 3804610120254550473, |
21 | 21 | "cell_origin": "client", |
22 | 22 | "cell_type": "input", |
23 | | - "source": "def diff(ex1, ex2):\n ret = $@(ex1)$\n sb = SympyBridge(ret)\n sb.from_sympy( str(sympy.diff( sb.to_sympy(), ex2 ) ) )\n return ret" |
| 23 | + "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" |
24 | 24 | }, |
25 | 25 | { |
26 | 26 | "cell_id": 12308609622224851480, |
|
43 | 43 | "cell_type": "input", |
44 | 44 | "cells": [ |
45 | 45 | { |
46 | | - "cell_id": 12523925591190418952, |
| 46 | + "cell_id": 1348085833411850626, |
47 | 47 | "cell_origin": "server", |
48 | 48 | "cell_type": "latex_view", |
49 | 49 | "cells": [ |
50 | 50 | { |
51 | | - "cell_id": 1379197150120835065, |
| 51 | + "cell_id": 16874039423838371410, |
52 | 52 | "cell_origin": "server", |
53 | 53 | "cell_type": "input_form", |
54 | | - "source": "\\sin(x) A_{\\mu}(x)" |
| 54 | + "source": "A_{\\mu}(x) \\cos(x) + \\sin(x) \\partial_{x}(A_{\\mu}(x))" |
55 | 55 | } |
56 | 56 | ], |
57 | | - "source": "\\begin{dmath*}{}\\sin{x} A_{\\mu}\\left(x\\right)\\end{dmath*}" |
58 | | - }, |
| 57 | + "source": "\\begin{dmath*}{}A_{\\mu}\\left(x\\right) \\cos{x}+\\sin{x} \\partial_{x}\\left(A_{\\mu}\\left(x\\right)\\right)\\end{dmath*}" |
| 58 | + } |
| 59 | + ], |
| 60 | + "ignore_on_import": true, |
| 61 | + "source": "diff($\\sin(x) A_{\\mu}(x)$, $x$);" |
| 62 | + }, |
| 63 | + { |
| 64 | + "cell_id": 549591636986061462, |
| 65 | + "cell_origin": "client", |
| 66 | + "cell_type": "input", |
| 67 | + "cells": [ |
59 | 68 | { |
60 | | - "cell_id": 7634624450130909684, |
| 69 | + "cell_id": 8841772239434008615, |
61 | 70 | "cell_origin": "server", |
62 | 71 | "cell_type": "latex_view", |
63 | 72 | "cells": [ |
64 | 73 | { |
65 | | - "cell_id": 1252059972554683227, |
| 74 | + "cell_id": 4066297813555277329, |
66 | 75 | "cell_origin": "server", |
67 | 76 | "cell_type": "input_form", |
68 | | - "source": "A_{\\mu}(x) \\cos(x) + \\sin(x) \\partial_{x}(A_{\\mu}(x))" |
| 77 | + "source": "-\\sin(y) \\cos(x)" |
69 | 78 | } |
70 | 79 | ], |
71 | | - "source": "\\begin{dmath*}{}A_{\\mu}\\left(x\\right) \\cos{x}+\\sin{x} \\partial_{x}\\left(A_{\\mu}\\left(x\\right)\\right)\\end{dmath*}" |
| 80 | + "source": "\\begin{dmath*}{}-\\sin{y} \\cos{x}\\end{dmath*}" |
72 | 81 | } |
73 | 82 | ], |
74 | | - "ignore_on_import": true, |
75 | | - "source": "ex:=\\sin(x) A_{\\mu}(x);\ndiff(ex, $x$);" |
| 83 | + "source": "diff($\\sin(x)\\cos(y)$, $x$, $y$);" |
76 | 84 | }, |
77 | 85 | { |
78 | 86 | "cell_id": 6234003092100779795, |
|
116 | 124 | "cell_type": "input", |
117 | 125 | "cells": [ |
118 | 126 | { |
119 | | - "cell_id": 12012117006062441490, |
| 127 | + "cell_id": 17063052500213847361, |
120 | 128 | "cell_origin": "server", |
121 | 129 | "cell_type": "latex_view", |
122 | 130 | "cells": [ |
123 | 131 | { |
124 | | - "cell_id": 316157390348515815, |
| 132 | + "cell_id": 7172967486322218859, |
125 | 133 | "cell_origin": "server", |
126 | 134 | "cell_type": "input_form", |
127 | 135 | "source": " 27/2 " |
|
154 | 162 | "cell_type": "input", |
155 | 163 | "cells": [ |
156 | 164 | { |
157 | | - "cell_id": 15728598564050855914, |
| 165 | + "cell_id": 5978718279542050921, |
158 | 166 | "cell_origin": "server", |
159 | 167 | "cell_type": "latex_view", |
160 | 168 | "cells": [ |
161 | 169 | { |
162 | | - "cell_id": 13682162971051715272, |
| 170 | + "cell_id": 4267217324248610000, |
163 | 171 | "cell_origin": "server", |
164 | 172 | "cell_type": "input_form", |
165 | 173 | "source": " 1/3 (x)**3 y" |
|
191 | 199 | "cell_type": "input", |
192 | 200 | "cells": [ |
193 | 201 | { |
194 | | - "cell_id": 4095815210246821736, |
| 202 | + "cell_id": 9023252122610197719, |
195 | 203 | "cell_origin": "server", |
196 | 204 | "cell_type": "latex_view", |
197 | 205 | "cells": [ |
198 | 206 | { |
199 | | - "cell_id": 13733098240311066994, |
| 207 | + "cell_id": 2730904024514227788, |
200 | 208 | "cell_origin": "server", |
201 | 209 | "cell_type": "input_form", |
202 | 210 | "source": " 1/4 (y)**2" |
|
0 commit comments