Ask Your Question

Revision history [back]

You can do

sage: f = function('f')
sage: var('h dt a1 a2 a3')
(h, dt, a1, a2, a3)
sage: dx = a1*h + a2*h^2 + a3*h^3
sage: s = taylor(f(x+dx), h, 0, 3); s
1/6*(a1^3*diff(f(x), x, x, x) + 6*a1*a2*diff(f(x), x, x) + 6*a3*diff(f(x), x))*h^3 + 1/2*(a1^2*diff(f(x), x, x) + 2*a2*diff(f(x), x))*h^2 + a1*h*diff(f(x), x) + f(x)
sage: sdt = s.subs({h: dt^(1/2)}); sdt
1/6*(a1^3*diff(f(x), x, x, x) + 6*a1*a2*diff(f(x), x, x) + 6*a3*diff(f(x), x))*dt^(3/2) + a1*sqrt(dt)*diff(f(x), x) + 1/2*(a1^2*diff(f(x), x, x) + 2*a2*diff(f(x), x))*dt + f(x)
sage: view(sdt)

$\frac{1}{6} {\left(a_{1}^{3} \frac{\partial^{3}}{(\partial x)^{3}}f\left(x\right) + 6 a_{1} a_{2} \frac{\partial^{2}}{(\partial x)^{2}}f\left(x\right) + 6 a_{3} \frac{\partial}{\partial x}f\left(x\right)\right)} \mathit{dt}^{\frac{3}{2}} + a_{1} \sqrt{\mathit{dt}} \frac{\partial}{\partial x}f\left(x\right) + \frac{1}{2} {\left(a_{1}^{2} \frac{\partial^{2}}{(\partial x)^{2}}f\left(x\right) + 2 a_{2} \frac{\partial}{\partial x}f\left(x\right)\right)} \mathit{dt} + f\left(x\right)$