# Symbolic Taylor expansion

I would like to expand the symbol function $f$ as a Taylor series $$\delta f(x)=\delta x\frac{d}{dx}f+\frac12(\delta x)^2\frac{d^2}{dx^2}f+O((\delta x)^3)$$ with $$\delta x = a_1(\delta t)^{\frac12}+a_2(\delta t)+a_3(\delta t)^{\frac32}+O((\delta t)^2)$$ and expand and collect the same power terms of $\delta t$ up to a designated power, say, $\frac32$. $f$ is just a symbol, I just need Mathsage to produce the symbols of derivatives $\frac{d}{dx}$.

How should one set this up?

Inspired by eric_g's answer to this question, I am able to perform the same operation to $f(x,y)$ with $$\delta y = a_1(\delta s)^{\frac12}+a_2(\delta s)+a_3(\delta s)^{\frac32}+O((\delta s)^2)$$. I would like to collect terms according to the powers $dt^{\frac i2}ds^{\frac j2}$ where $i$ and $j$ are nonnegative integers and arranged in the ascending order of $i+j$. I would also like to have the capacity to collect terms according to the order of some other variables, say, $a_1$. I have tried using

g.full_simplify().maxima_methods().collectterms(dt)

for a single variable $dt$. But it does not seem to work well for the fractional power. I do not know if it will work for $dt^{\frac i2}ds^{\frac j2}$.

How can I set this up?