# General formula for $e^x+\cos(x)$, $e^x+\sin(x)$, $e^x-\sin(x)$, $e^x-\sin(x)$

I have been able to derive the formal series for these four functions:

$$e^x+\sin(x) = 1+2x+\dfrac{x^2}{2!}+\dfrac{x^4}{4!}+\dfrac{2x^5}{5!}+\dfrac{x^6}{6!}+\dfrac{x^8}{8!}+\dfrac{2x^9}{9!}+...$$

$$e^x+\cos(x) = 2+\dfrac{x^3}{3!}+\dfrac{2x^4}{4!}+\dfrac{x^5}{5!}+\dfrac{x^7}{7!}+\dfrac{2x^8}{8!}+...$$

$$e^x-\sin(x) = 1+\dfrac{x^2}{2!}+\dfrac{2x^3}{3!}+\dfrac{x^4}{4!}+\dfrac{2x^7}{7!}+\dfrac{x^8}{8!}+...$$

$$e^x-\cos(x) = x+x^2+\dfrac{x^3}{3!}+\dfrac{x^5}{5!}+\dfrac{2x^6}{6!}+\dfrac{x^7}{7!}+\dfrac{x^9}{9!}+...$$

Due to the missing term and the irregularity, I am unable to write the general formula for these series. I wish to find the general formula with compact sigma notation. Can you help with this?

Formal power series can be added and then their area of convergence is limited by the most restricted one.

So one easy way would be to

1. find separately expansions for $$\{e^{x},\cos(x),\sin(x)\}$$

2. add (or subtract) them to each other

3. put them under the same $$\sum$$ and then

4. try to simplify the expression you get using algebra.

Take the series for $$e^x+\sin x$$ for example. This is obtained by taking the series for $$e^x$$, doubling the terms $$\dfrac{x^n}{n!}$$ for $$n=4k+1$$ and deleting the terms $$\dfrac{x^n}{n!}$$ for $$n=4k+3$$. So you could write it as $$\sum_{k=0}^{\infty} \left( \dfrac{x^{4k}}{(4k)!} + \dfrac{2x^{4k+1}}{(4k+1)!} + \dfrac{x^{4k+2}}{(4k+2)!} \right)$$

Alternatively, let $$i_n = \begin{cases} 1 & \text{if } n = 4k \text{ or } 4k+2 \\ 2 & \text{if } n=4k+1 \\ 0 & \text{if } n=4k+3 \end{cases}$$ so that the sequence $$(i_n)_{n \ge 0}$$ is given by $$1,2,1,0,1,2,1,0,\dots$$; then you have $$e^x + \sin x = \sum_{n=0}^{\infty} \dfrac{i_n x^n}{n!}$$ Now note that $$i_n = 1 + \sin \dfrac{n\pi}{2}$$, to give you $$\boxed{e^x + \sin x = \sum_{n=0}^{\infty} \left( 1 + \sin \frac{n\pi}{2} \right) \dfrac{x^n}{n!}}$$

You can do a similar trick for the other sequences you desire.

If you don't like using the sine function inside the sum, then you can notice that $$i_n = 1 + \dfrac{i^n-i^{-n}}{2}$$, where $$i^2=-1$$; this gives $$\boxed{e^x + \sin x = \sum_{n=0}^{\infty} \left( 1 + \dfrac{i^n-i^{-n}}{2} \right) \dfrac{x^n}{n!}}$$

If you don't like using the sine function or complex numbers inside the sum, you can do some fiddling around with floor functions and powers of $$-1$$ to get an equivalent expression. For example: $$i_n = \dfrac{1-(-1)^n}{2} \cdot (-1)^{\frac{1}{2}\left(n - \left\lfloor \frac{n}{4} \right\rfloor - 1\right)}$$ so you can write $$\boxed{e^x + \sin x = \sum_{n=0}^{\infty} \dfrac{1-(-1)^n}{2} \cdot (-1)^{\frac{1}{2}\left(n - \left\lfloor \frac{n}{4} \right\rfloor - 1\right)} \cdot \dfrac{x^n}{n!}}$$

• How do you come up with $4k+1$ and $4k+2$ so fast? – James Warthington Nov 10 '19 at 19:57
• @JamesWarthington: The pattern $1,2,1,0,1,2,1,0,\dots$ is periodic with period $4$, so whatever you're going to do to modify the series for $e^x$ is going to have something to do with remainders upon division by $4$. – Clive Newstead Nov 10 '19 at 19:59

If the terms in the series for the two functions you're adding or subtracting had the same numbering scheme, you could easily add or subtract them term by term within the same numbering scheme.

The reason you cannot do this with the usual series for these functions is that the $$n$$th term in the series for $$e^x$$ is the term in $$x^n$$ (numbering the terms starting with $$n=0$$), whereas for $$\sin x$$ the $$n$$th term is the term in $$x^{2n+1}$$: $$\sin (x) = \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)!}x^{2n+1} .$$

To fix this, we need a function $$f$$ over integers such that $$f(n) = \begin{cases} \phantom{-}0 &&& n \equiv 0 \pmod 4,\\ \phantom{-}1 &&& n \equiv 1 \pmod 4,\\ \phantom{-}0 &&& n \equiv 2 \pmod 4,\\ -1 &&& n \equiv 3 \pmod 4. \end{cases}$$

This function can be written compactly using the formula $$\Im(i^n),$$ the imaginary part of the $$n$$th power of the imaginary unit. Alternatively, $$\sin\left(\frac\pi2 n\right)$$ will do just as well. You could even use an expression like $$\frac12(1 - (-1)^n)(-1)^{\lfloor n/2\rfloor},$$ thereby avoiding all hints of imaginary numbers or trig functions. But we could just define $$f$$ by cases as shown above in order to have less obscure jiggery-pokery in our formulas.

So we can write \begin{align} e^x &= \sum_{n=0}^\infty \frac{1}{n!} x^n, \\ \sin(x) &= \sum_{n=0}^\infty \frac{f(n)}{n!} x^n, \\ \cos(x) &= \sum_{n=0}^\infty \frac{f(n+1)}{n!} x^n. \\ \end{align}

Now it should not be hard to add or subtract these series term by term. For example, $$e^x - \sin(x) = \sum_{n=0}^\infty \frac{1 - f(n)}{n!} x^n$$