Can anyone explain the logic behind this taylor series expansion?

I know the general equations for a taylor series and understand where the first term came from, but I do not understand where the 2nd or 3rd terms are derived from.
Can anyone explain the logic behind this taylor series expansion?

I know the general equations for a taylor series and understand where the first term came from, but I do not understand where the 2nd or 3rd terms are derived from.
On
I am a new calculus student so I may not get this completely correct so if I get anything wrong please don't insult me in the comments just correct me and I will fix it.
I am assuming that you are asking about the formula of the taylor series $$f(x)=\sum_{n=0}^{\infty}\frac{f^n(a)}{n!}(x-a)^n$$ And if not I would recommend you read How to ask a good question..
Note: the McLauren series is the same as the taylor series except a = 0
Lets answer this question by trying to create McLauren series ourselves from scratch. For this example we will try to approximate cos(x). Wouldn't it be nice if we had a function that looked like $$c_0 + c_1x + c_2x^2 + ...+c_nx^n$$ We know that $$cos(0) = 1$$ So we make $$c_o = 1$$We also want this function to have the same first derivative at cos(0). We do this by taking the derivative of the equation so far$$\frac{d}{dx}(1+c_1x+c_2x^2)=c_1 + 2c_2x$$ And we know that $$\frac{d}{dx}(cos(x)) = -sin(x)$$ $$-sin(0)=0$$ $$c_1=0$$ So our approximation of cos(x) so far is $$1+0x+c_2x^2$$ We also want the second derivative of our approximation to equal the second derivative of cos(x) $$\frac{d^2}{dx^2}(cos(x))=-cos(x)$$ $$\frac{d^2}{dx^2}(c_0 + c_1x + c_2x^2)=2c_2$$ $$-cos(0)=-1$$ $$2c_2=-1$$ $$c_2=-\frac{1}{2}$$ So our approximation so far is $$1 + 0x + (-\frac{1}{2})x^2$$ And if we simplify this we get $$1 -\frac{x^2}{2}$$ And if we continue this process our approximation gets closer and closer to cos(x), and if we do this an infinite amount of times the approximation will be exactly equal to cos(x). This brings us back to the original formula $$f(x)=\sum_{n=0}^{\infty}\frac{f^n(0)}{n!}x^n$$ The last thing we need to resolve is why x! is there. The reason is because of the power rule. $$\frac{d}{dx}x^n=nx^{n-1}$$ Lets say we want to find the third derivative of c3x3 to find what c3 should be in our approximation of cos(x). $$\frac{d}{dx}c_3x^3=3*c_3x^2$$ $$\frac{d^2}{dx^2}c_3x^3=2*3*c_3x^1$$ $$\frac{d^3}{dx^3}c_3x^3=1*2*3*c_3=3!c_3$$ And we know the third derivative of cos(x) is sin(x) $$3!c_3=sin(0)$$ $$sin(0)=0$$ $$3!c_3=0$$ $$c_3=\frac{0}{3!}$$ $$c_3 = 0$$ And this is why we divide by n!.
So in recap we create a formula that looks like c0+c1x + c2x2+... Then we find the nth derivative of f(x) and the function we just created and match up the terms.
I know that this questions was asked 5 years ago but this might be helpful to somebody else that is curious about how the taylor series formula works.
Hopefully this helps!
Taylor polynomial about $x_0$is a polynomial $p(x)$ with the property that:
$$p(x_0)=f(x_0)$$ $$p'(x_0)=f'(x_0)$$ $$p''(x_0)=f''(x_0)$$ up to $$p^{(n)}(x_0)=f^{(n)}(x_0)$$
Suppose $$p(x) = a_0 + a_1(x-x_0) + a_2(x-x_0)^2+ ...+ a_n ( x-x_0)^n$$
For $x=x_0$ we get $$ p(x_0) = a_0 = f(x_0)$$
$$ p'(x_0) = a_1 = f'(x_0) $$ $$ p''(x_0) = 2a_2 = f''(x_0)\implies a_2 = (1/2)f''(x_0)$$
Similarly you get $$a_n = (1/{n!})f^{(n)}(x_0)$$