︠96ea5532-c672-4a8c-bca8-a52cd7020b24i︠ %md Differentiating functions in SageMath http://doc.sagemath.org/html/en/tutorial/tour_algebra.html#solving-differential-equations ︡9eafe483-de15-4ba0-8762-0a7dc68a0289︡{"done":true,"md":"\nDifferentiating functions in SageMath\n\nhttp://doc.sagemath.org/html/en/tutorial/tour_algebra.html#solving-differential-equations"} ︠50b159c4-8686-4461-9910-626a497ace0cs︠ x = var('x') a = function('a')(x) b = function('b')(x) ab1 = diff(a * b, x) show(ab1) ︡52b1c172-b45e-4765-8d1e-25c8051d3b0b︡{"html":"
$\\displaystyle b\\left(x\\right) \\frac{\\partial}{\\partial x}a\\left(x\\right) + a\\left(x\\right) \\frac{\\partial}{\\partial x}b\\left(x\\right)$
"}︡{"done":true} ︠051720f2-9298-454a-8829-83e52539118as︠ show(diff(2 * a + 3 * b^2, x)) ︡87e7f165-3166-426d-9738-0a185e8312ff︡{"html":"
$\\displaystyle 6 \\, b\\left(x\\right) \\frac{\\partial}{\\partial x}b\\left(x\\right) + 2 \\, \\frac{\\partial}{\\partial x}a\\left(x\\right)$
"}︡{"done":true} ︠8559f4c6-4852-49a8-8b22-195c579676a3s︠ # chain rule. # be explicit about what x is, i.e. a(x= ... ) t = var('t') show(diff(a(x = t^2 + b(x = x^2)), x)) ︡244c08b7-e841-466e-87e7-8afca3abf521︡{"html":"
$\\displaystyle 2 \\, x \\mathrm{D}_{0}\\left(a\\right)\\left(t^{2} + b\\left(x^{2}\\right)\\right) \\mathrm{D}_{0}\\left(b\\right)\\left(x^{2}\\right)$
"}︡{"done":true} ︠9f273c20-921a-4d61-8d8d-8a8734b15868s︠ ex3 = (a - 2*b)^3 / (b(x = 2*a(x=x)))^2 show(ex3) ︡0b180b84-39fc-4ddc-b346-852037af412a︡{"html":"
$\\displaystyle \\frac{{\\left(a\\left(x\\right) - 2 \\, b\\left(x\\right)\\right)}^{3}}{b\\left(2 \\, a\\left(x\\right)\\right)^{2}}$
"}︡{"done":true} ︠75336b99-5e32-4776-939d-a6387192cd62s︠ show(diff(ex3, x)) ︡98d7643b-7ca9-4cd8-9a94-e653c59023b4︡{"html":"
$\\displaystyle -\\frac{4 \\, {\\left(a\\left(x\\right) - 2 \\, b\\left(x\\right)\\right)}^{3} \\frac{\\partial}{\\partial x}a\\left(x\\right) \\mathrm{D}_{0}\\left(b\\right)\\left(2 \\, a\\left(x\\right)\\right)}{b\\left(2 \\, a\\left(x\\right)\\right)^{3}} + \\frac{3 \\, {\\left(a\\left(x\\right) - 2 \\, b\\left(x\\right)\\right)}^{2} {\\left(\\frac{\\partial}{\\partial x}a\\left(x\\right) - 2 \\, \\frac{\\partial}{\\partial x}b\\left(x\\right)\\right)}}{b\\left(2 \\, a\\left(x\\right)\\right)^{2}}$
"}︡{"done":true} ︠0063194f-d93a-4673-8270-5b329fd3295ds︠ ︡a529cd93-e1d5-484f-aaa9-66eb418df29b︡{"done":true}