How to find the Maclaurin series for $f(x) = \frac{1}{1 + \sin(x)}$? I have that $\frac{1}{1 + x} = 1 - x + x^2 - x^3 + ...$
So then $\frac{1}{1 + \sin(x)}$ should be $ 1 - \sin(x) + \sin^2(x) - \sin^3(x) + ...$ but clearly this is not the case. 
So how does substitution into Maclaurin series work and why does this not work? 
 A: By substitution of the expansion of $\sin x$ at the required order in the expansion of $\dfrac1{1+u}$ at the same order.
Example for order 5:
$$\dfrac1{1+u}=1-u+u^2-u^3+u^4-u^5+o(u),\qquad \sin x=x-\frac{x^3}6+\frac{x^5}{120}+o(x5),$$
whence
\begin{align*}
\sin^2x&=x^2-\frac{x^4}3+o(x^5)&\sin^3x&=\Bigl(x^2-\frac{x^4}3+o(x^5)\Bigr)\Bigl(x-\frac{x^3}6+\frac{x^5}{120}+o(x^5)\Bigr)=x^3-\frac{x^5}2+o(x^5)\\
\sin^4x&=x^4+o(x^5)& \sin^5x&=x^5,
\end{align*}
so we have
\begin{align*}
\dfrac1{1+\sin x}&=1-\Bigl(x-\frac{x^3}6+\frac{x^5}{120}\Bigr)+\Bigl(x^2-\frac{x^4}3\Bigr)-\Bigl(x^3-\frac{x^5}2\Bigr)+x^4-x^5+o(x^5)\\&=1-x+x^2-\frac{5x^3}6+\frac{2x^4}3-\frac{61x^5}{120}+o(x^5).
\end{align*}
A: For $k,m\in\mathbb{N}=\{1,2,\dotsc\}$, partial Bell polynomials $\textrm{B}_{m,k}$ satisfy
\begin{equation}\label{bell-polyn-2m-1}\tag{BQF1}
\textrm{B}_{2m+k-1,k}(1,0,-1,0,\dotsc, \sin(m\pi))=0
\end{equation}
and
\begin{equation}\label{bell-polyn-2m}\tag{BQF2}
\textrm{B}_{2m+k,k}\biggl(1,0,-1,0,\dotsc, \sin\frac{(2m+1)\pi}{2}\biggr)
=(-1)^{m} 2^{2m} R\biggl(2m+k,k,-\frac{k}{2}\biggr),
\end{equation}
where
\begin{equation}\label{S(n,k,x)-satisfy-eq}
R(n,k,r)=\frac1{k!}\sum_{j=0}^k(-1)^{k-j}\binom{k}{j}(r+j)^n
\end{equation}
for $r\in\mathbb{R}$ and $n\ge k\ge0$ denotes weighted Stirling numbers of the second kind, see Carlitz's paper [1] below.
For proofs and applications of the formulas \eqref{bell-polyn-2m-1} and \eqref{bell-polyn-2m}, please see Theorem 1.2 in [2] and Section 1.6 in [3] below.
By virtue of the Faa di Bruno formula and the formulas \eqref{bell-polyn-2m-1} and \eqref{bell-polyn-2m}, one can readily discover the series expansion
\begin{equation}\label{sin-recip-ser-expan}\tag{SQE}
\boxed{\frac{1}{1+\sin x}=1+\sum_{k=1}^{\infty}(-1)^{k}\Biggl[\sum_{\ell=0}^{\lfloor{(k-1)/2}\rfloor} (-1)^{\ell} (k-2\ell)! 2^{2\ell} R\biggl(k,k-2\ell,-\frac{k-2\ell}{2}\biggr)\Biggr]\frac{x^k}{k!}}
\end{equation}
for $|x|<\frac{\pi}{2}$, where $\bigl\lfloor{\frac{k-1}{2}}\bigr\rfloor$ stands for the floor function whose value is equal to the largest integer less than or equal to $\frac{k-1}{2}$.
References

*

*L. Carlitz, Weighted Stirling numbers of the first and second kind, I, Fibonacci Quart. 18 (1980), no. 2, 147--162.

*F. Qi, Derivatives of tangent function and tangent numbers, Appl. Math. Comput. 268 (2015), 844--858; available online at http://dx.doi.org/10.1016/j.amc.2015.06.123.

*F. Qi, D.-W. Niu, D. Lim, and Y.-H. Yao, Special values of the Bell polynomials of the second kind for some sequences and functions, J. Math. Anal. Appl. 491 (2020), no. 2, Article 124382, 31 pages; available online at https://doi.org/10.1016/j.jmaa.2020.124382.

