What functions, if any, can NOT be approximated by a Taylor series? [duplicate]

I am taking some courses online (machine learning) and the instructor noted that a Taylor series can be used to approximate any function. A student left a comment that a Taylor series cannot approximate ANY function, but noted that the instructor probably stated it unequivocally because it can certainly approximate any function we would need for the class.

I am curious, what functions cannot be approximated by a Taylor series?

Two things lead me to believe that any function CAN be approximated by a Taylor series:

1. In context of regression, it seems I can always continue to add terms and adjust the coefficients on those terms (or solve for them to reduce the error) to continually get a better approximation of points in my data set.
2. The ambiguity of the word approximate suggests that we don't have to meet a strict criteria to say that a Taylor series approximates a function.

With those things in mind, I can also see a point to the opposite view. For example, a function with large discontinuities such as

$f(x) = \begin{cases}sin(x)/x^2 & \text{if$x < 0$} \\ 2x & \text{if$x > 100$}\end{cases}$

seems like it wouldn't be well approximated by a Taylor series. But then again, without some defenition of approximate, I don't see how we can say either way.

marked as duplicate by Xander Henderson, Namaste calculus StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jul 8 '18 at 14:17

• Taylor series approximations only "work" in a neighborhood of some point---they only converge on some open disk centered at the point where the expansion is based. Assuming that a function has enough derivatives, the approximation can be made as good as possible on that disk, and will blow up away from that disk. – Xander Henderson Jul 8 '18 at 3:00
• See e.g. MSE 2125155. You may also wish to read up on analytic functions (you want functions that are not analytic...). Wikilink: en.wikipedia.org/wiki/Analytic_function – Benjamin Dickman Jul 8 '18 at 3:01
• Sorry I did search the site before posting by I think my wording was poor. I will refer to the other post. – Hanzy Jul 8 '18 at 3:02
• I guess I took differentiability for granted. Maybe that was the point of contention by the other student, but it wasn’t stated specifically. – Hanzy Jul 8 '18 at 3:08
• @Hanzy In the case of a better search you may also want to see the "related posts " on the right side of the web page or else you can search your questions using approach0.xyz , hope this will help u search better questions again. – BAYMAX Jul 8 '18 at 3:30

Notice that to have a taylor series, our function must be smooth (e.g. infinitely continuously differentiable). Hence, a counter example will be any function that isn't smooth. Indeed, a simple counter example is \begin{align} f(x) = |x| \end{align} We cannot obtain a taylor series around $x=0$ because $f'(0)$ is not continuous.

For more sophiscated counter examples where $f$ is smooth, https://en.wikipedia.org/wiki/Non-analytic_smooth_function.

But a curious fact is that for a complex valued function $g$, then $g$ is smooth if and only if it's analytic(e.g. has a taylor series).

Here's a function that is smooth (infinitely differentiable) but fails to have a Taylor series at $x=0$:

Consider $f(x)=e^{-\frac{1}{x^2}}$ for $x \in \mathbb{R}-0$ and $f(0)=0$.

Show that $f^{(n)}=0$ and therefore the Taylor series for this function, if it existed, must be $0$. While this function is clearly not constant in any neighborhood of $0$.

In general, analytic functions have Taylor series. This is pretty much the definition of an analytic function as far as I'm aware.