How to save Taylor series coefficients into an array in Matlab script

This question is in the context of a .m script.

I know how to get a number of Taylor functions, but I do not see any command that allows storing the series coefficients in an array - sym2polyit does not seem to work.

How to store coefficients in an array? For example, this function:

syms x
f = 1/(x^2+4*x+9)

How can we get the Taylor coefficients? fntlrdoes not work.

+4
source share
1 answer

Using your example, it is symbolic taylorand coeffscan be used to obtain a vector of coefficients:

syms x
f = 1/(x^2 + 4*x + 9);
ts = taylor(f,x,0,'Order',4) % 4-th order Taylor series of f about 0
c = coeffs(ts)

which returns

ts =

(8*x^3)/6561 + (7*x^2)/729 - (4*x)/81 + 1/9


c =

[ 1/9, -4/81, 7/729, 8/6561]

vpa double, c .

+5

Source: https://habr.com/ru/post/1615913/


All Articles