The documentation for the COEFFS function does not specify that the results will be in any specific order. If you change the call to COEFFS from:
t = coeffs(taylor(f,tot))'
to
[t u]=coeffs(taylor(f,tot))'
You will see that the coefficients match with the order of polynomial.
You can post-process the output by finding out the order and sorting it to ascending order.
For example, if the output is as follows:
t =
[ 1, 1/362880, 1/3628800, 1/5040, 1/40320, 1, 1/2, 1/6, 1/24, 1/120, 1/720]
u =
[ 1, x^9, x^10, x^7, x^8, x, x^2, x^3, x^4, x^5, x^6]
Add these lines of code to find the order:
syms x positive;
order = log(u)/log(x)
Then you can rearrange "t" according to the values returned by "order".
Best Answer