\documentclass[11pt]{amsart}
\usepackage{amssymb,amsmath,fullpage,amsthm}

\newcommand{\dd}{\,d}
\newcommand{\intl}{\int\limits}
\newcommand{\liml}{\lim\limits}
\newcommand{\suml}{\sum\limits}

\newtheorem{theorem}{Theorem}

\begin{document}

\title{Integrating and differentiating series of powers of functions}

\author{David Milovich}

\maketitle

Let $g(x)$ be such that $g'(x)$ exists and is continuous;
let $c_0,c_1,c_2,\ldots$ be a sequence of constants.
Suppose that $\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}(g(x))^{k+1}}{c_k(g(x))^k}\right\rvert$ exists and is $<1$ for all $x$ in some interval $[a,b]$, except where $g(x)=0$.
By the ratio test, $\suml_{k=0}^\infty c_k(g(x))^k$ converges for
all $x$ in $[a,b]$.  Call this sum $f(x)$.

We would hope that 
$$\intl_a^bf(x)\dd x=\suml_{k=0}^\infty \left(c_k\intl_a^bg(x)^k\dd x\right)$$ 
and, when $a<x<b$,
$$\frac{df}{dx}=\suml_{k=0}^\infty\left(c_k\frac{d(g(x)^k)}{dx}\right),$$
but hope is not a proof, and, despite how natural they look, 
these equations are not obviously true.

For example, it can be shown that $\suml_{k=1}^\infty\frac{\sin kx}{k}$ 
is discontinuous (and therefore not differentiable)
at the points $x=0,\pm 2\pi,\pm 4\pi,\ldots$.
(At these $x$-valus, the value of the sum is $0$, 
the limit from the left is $-\pi/2$, and 
the limit from the right is $+\pi/2$.
Plot $\suml_{k=1}^{10}\frac{\sin kx}{k}$ to see an
approximation of these discontinuities.)
These discontinuities occur even though the 
series converges for all $x$, and $\frac{\sin kx}{k}$ can differentiated
(with respect to $x$) as many times as we like.

The purpose of this note is to prove that,
under our assumptions listed in the first paragraph,
we can safely integrate and differentiate 
$f(x)=\suml_{k=0}^\infty c_kg(x)^k$  term by term.

\begin{theorem}
Let $g(x)$ be continuous on $[a,b]$;
let $c_0,c_1,c_2,\ldots$ be a sequence of constants.
Suppose that $\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}g(x)^{k+1}}{c_kg(x)^k}\right\rvert$ 
exists and is $<1$ for all $x$ in $[a,b]$, except where $g(x)=0$.
It follows that 
$$\intl_a^b\left(\suml_{k=0}^\infty c_k g(x)^k\right)\dd x=\suml_{k=0}^\infty\left(\intl_a^bc_k g(x)^k\dd x\right).$$
\end{theorem}
\begin{proof}
Let $f(x)=\suml_{k=0}^\infty c_k g(x)^k$, 
which, by the ratio test, converges for all $x$ in $[a,b]$.  
Before we can talk about what $\intl_a^b f(x)\dd x$ equals,
we need to show that it exists.
To show that this integral exists,
it is sufficient (see section 4.2 of Keisler's book \cite{keisler}) 
to show that $f(x)$ is continuous on $[a,b]$.

To show continuity, we must show that if $u$, $v$ are in $[a,b]$
and $u\approx v$, then $f(u)\approx f(v)$.  
For any finite $n$, $\suml_{k=0}^n c_kg(x)^k$ 
is just a finite sum of constant multiples of $g(x)$, 
so it is continuous on $[a,b]$,
so $\suml_{k=0}^n c_kg(u)^k\approx\suml_{k=0}^n c_kg(v)^k$.
We can break up $f(x)$ into two sums:  
$f(x)=\suml_{k=0}^n c_kg(x)^k+\suml_{k=n+1}^\infty c_kg(x)^k$.
Therefore,
$$f(u)-f(v)=\suml_{k=0}^n c_kg(u)^k-\suml_{k=0}^n c_kg(v)^k+\suml_{k=n+1}^\infty c_kg(u)^k-\suml_{k=n+1}^\infty c_kg(v)^k,$$
which, since $\suml_{k=0}^n c_kg(u)^k\approx\suml_{k=0}^n c_kg(v)^k$, implies 
$$f(u)-f(v)\approx\suml_{k=n+1}^\infty c_kg(u)^k-\suml_{k=n+1}^\infty c_kg(v)^k.$$
Therefore, no matter what our choice of $n$,
$\suml_{k=n+1}^\infty c_kg(u)^k-\suml_{k=n+1}^\infty c_kg(v)^k$ is infinitely
close to the same real, the standard part of $f(u)-f(v)$; 
call this real $s$.
We will next show that $s=0$, 
which implies that $f(u)-f(v)\approx 0$, 
from which our desired claim $f(u)\approx f(v)$ follows immediately.

Let us use our assumption that
 $\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}g(x)^{k+1}}{c_kg(x)^k}\right\rvert$ 
exists and is $<1$ for all $x$ in $[a,b]$ where $g(x)\not=0$.
The theorem is trivially true is $g(x)=0$ on all of $[a,b]$, 
so we may assume that $g(x_1)\not=0$ for some $x_1$ in $[a,b]$.
First, notice that $\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}g(x_1)^{k+1}}{c_kg(x_1)^k}\right\rvert
=\lvert g(x_1)\rvert\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}}{c_k}\right\rvert$,
so $\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}}{c_k}\right\rvert$ exists;
call this limit $L$.
We now have $\lvert g(x)\rvert L<1$ for all $x$ in $[a,b]$.
Since $g(x)$ is continuous on $[a,b]$ and $\lvert x\rvert$
is continuous everywhere, $\lvert g(x)\rvert$ is continuous.
Therefore, by the Extreme Value Theorem (section 3.8 of \cite{keisler}),
there is some real $x_0$ in $[a,b]$ such that
$\lvert g(x_0)\rvert\geq\lvert g(x)\rvert$ for all $x$ in $[a,b]$;
let $M=\lvert g(x_0)\rvert$.
It follows that $ML=\lvert g(x_0)\rvert L<1$;
choose a real $p$ such that $ML<p<1$.
(One possible choice is the midpoint $(ML+1)/2)$.)
We then have $L<p/M$.
When $H$ is an infinite positive hyperinteger,
$\left\lvert\frac{c_{H+1}}{c_H}\right\rvert\approx L$, 
so $\left\lvert\frac{c_{H+1}}{c_H}\right\rvert<p/M$.
Every $n\geq H$ is also infinite, so
$\left\lvert\frac{c_{m+1}}{c_m}\right\rvert<p/M$ for all $m\geq H$.
By the Transfer Principle, 
there is a standard (finite) integer $h$ such that
$\left\lvert\frac{c_{m+1}}{c_m}\right\rvert<p/M$ for all $m\geq h$.
Therefore, for all $k\geq h$, we have
$$\lvert c_k\rvert=\left\lvert c_h\frac{c_{h+1}}{c_h}\frac{c_{h+2}}{c_{h+1}}\frac{c_{h+3}}{c_{h+2}}\cdots\frac{c_k}{c_{k-1}}\right\rvert<\lvert c_h\rvert \left(\frac{p}{M}\right)^{k-h},$$
which implies $-\lvert c_h\rvert \left(\frac{p}{M}\right)^{k-h}<c_k<\lvert c_h\rvert \left(\frac{p}{M}\right)^{k-h}$.
Therefore, whenever $n+1\geq h$ and $x$ is in $[a,b]$, we have
$$-\lvert c_h\rvert \suml_{k=n+1}^\infty \left(\frac{p}{M}\right)^{k-h}g(x)^k<\suml_{k=n+1}^\infty c_kg(x)^k<\lvert c_h\rvert \suml_{k=n+1}^\infty \left(\frac{p}{M}\right)^{k-h}g(x)^k.$$
Since $\lvert g(x)\rvert\leq M$, we have $-M<g(x)<M$, so
$$-\lvert c_h\rvert \suml_{k=n+1}^\infty \left(\frac{p}{M}\right)^{k-h}M^k<\suml_{k=n+1}^\infty c_kg(x)^k<\lvert c_h\rvert \suml_{k=n+1}^\infty \left(\frac{p}{M}\right)^{k-h}M^k.$$
To ultimately get geometric series, we substitute $w=k-n-1$ (which implies $k=w+n+1$) into the left and right series:
$$-\lvert c_h\rvert \suml_{w=0}^\infty \left(\frac{p}{M}\right)^{w+n+1-h}M^{w+n+1}<\suml_{k=n+1}^\infty c_kg(x)^k<\lvert c_h\rvert \suml_{w=0}^\infty \left(\frac{p}{M}\right)^{w+n+1-h}M^{w+n+1}.$$
Simplifying, geometric series appear:
$$-\lvert c_h\rvert p^{n+1-h}M^h\suml_{w=0}^\infty p^w<\suml_{k=n+1}^\infty c_kg(x)^k<\lvert c_h\rvert p^{n+1-h}M^h\suml_{w=0}^\infty p^w.$$
Evaluating these geometric series, we have
$$-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}<\suml_{k=n+1}^\infty c_kg(x)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}.$$
Since the above is true for all $x$ in $[a,b]$, it is true if we replace $x$ by $u$ or $v$:
\begin{align*}
-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}<\suml_{k=n+1}^\infty c_kg(u)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}\\
-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}<\suml_{k=n+1}^\infty c_kg(v)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}
\end{align*}
Multiplying the bottom line by $-1$, we get
$$\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}>-\suml_{k=n+1}^\infty c_kg(v)^k>-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p},$$
which we can rewrite as 
$$-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}<-\suml_{k=n+1}^\infty c_kg(v)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p},$$
Therefore,
\begin{align*}
-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}&<\suml_{k=n+1}^\infty c_kg(u)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}\\
-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}&<-\suml_{k=n+1}^\infty c_kg(v)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}
\end{align*}
Adding the last two lines,
$$-2\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}<\suml_{k=n+1}^\infty c_kg(u)^k-\suml_{k=n+1}^\infty c_kg(v)^k<2\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}.$$
The expression $2\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}$ is just a constant multiple of $p^n$, and
as $\liml_{n\rightarrow\infty}p^n=0$ because $0\leq p<1$.
Hence,  $\liml_{n\rightarrow\infty}2\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}=0$.
Therefore, for every positive real $r$, as $n$ increases, 
$\suml_{k=n+1}^\infty c_kg(u)^k-\suml_{k=n+1}^\infty c_kg(v)^k$ 
is strictly between $-r$ and $r$.
Since $s\approx\suml_{k=n+1}^\infty c_kg(u)^k-\suml_{k=n+1}^\infty c_kg(v)^k$ for all $n$,
it follows that $-r<s<r$ for all positive reals $r$.
Since $s$ is real, $s=0$, as we set out to show.
Thus, $f$ is continuous on $[a,b]$, and so $\intl_a^b f(x)\dd x$ exists.

Now we must show that $\intl_a^b f(x)\dd x=\suml_{k=0}^\infty\left(c_k\intl_a^bg(x)^k\dd x\right)$.
This is equation is equivalent to $\intl_a^b f(x)\dd x-\suml_{k=0}^\infty\left(c_k\intl_a^bg(x)^k\dd x\right)=0$.
Since $\suml_{k=0}^\infty\left(c_k\intl_a^bg(x)^k\dd x\right)=\liml_{n\rightarrow\infty}\suml_{k=0}^n\left(c_k\intl_a^bg(x)^k\dd x\right)$, 
we just need to show that 
 $\liml_{n\rightarrow\infty}\left[\intl_a^b f(x)\dd x-\suml_{k=0}^n\left(c_k\intl_a^bg(x)^k\dd x\right)\right]=0$.
Inside this last limit, for each $n$, 
we just have finitely many integrals being added and subtracted,
so we can rewrite the limit as
$\liml_{n\rightarrow\infty}\intl_a^b\left[f(x)-\suml_{k=0}^nc_kg(x)^k\right]\dd x$.
Since $f(x)=\suml_{k=0}^\infty c_k g(x)^k$, the limit is
$\liml_{n\rightarrow\infty}\intl_a^b\left[\suml_{k=n+1}^\infty c_kg(x)^k\right]\dd x$.
We have already shown that when $n+1\geq h$,
$$-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}<\suml_{k=n+1}^\infty c_kg(x)^k<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}.$$
Therefore,
$$-\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}(b-a)<\intl_a^b\left[\suml_{k=n+1}^\infty c_kg(x)^k\right]\dd x<\lvert c_h\rvert \frac{p^{n+1-h}M^h}{1-p}(b-a).$$
As $n\rightarrow\infty$, the left and right sides $\rightarrow 0$ because $p^n\rightarrow 0$.
Therefore, $\liml_{n\rightarrow\infty}\intl_a^b\left[\suml_{k=n+1}^\infty c_kg(x)^k\right]\dd x=0$, completing
the proof.
\end{proof}


\begin{theorem}
Let $g(x)$ be such that $g'(x)$ exists and is continuous on an open interval $I$;
let $c_0,c_1,c_2,\ldots$ be a sequence of constants.
Suppose that $\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}(g(x))^{k+1}}{c_k(g(x))^k}\right\rvert$ exists and is $<1$ for all $x$ in $I$.
It follows that, for all $x$ in $I$, except where $g(x)=0$,
$$\frac{d}{dx}\suml_{k=0}^\infty c_k g(x)^k=\suml_{k=0}^\infty c_k\frac{d(g(x)^k)}{dx}.$$
Moreover, the ratio-test limit is the same before and after differentiation:
$$\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}d(g(x)^{k+1})/dx}{c_kd(g(x)^k)/dx}\right\rvert
=\liml_{k\rightarrow\infty}\left\lvert\frac{c_{k+1}(g(x))^{k+1}}{c_k(g(x))^k}\right\rvert<1,$$
except where $g(x)=0$ or $g'(x)=0$.
\end{theorem}
\begin{proof}
Let $f(x)=\suml_{k=0}^\infty c_k g(x)^k$,
which, by the ratio test, converges for all $x$ in $[a,b]$.  
Let $S(x)=\suml_{k=0}^\infty c_k\frac{d(g(x)^k)}{dx}$;
we must prove that $S(x)$ converges and that $f'(x)=S(x)$,
for all $x$ in $I$.

By the chain rule,
$$S(x)=\suml_{k=0}^\infty c_k\frac{kg(x)^{k-1}d(g(x))}{dx}=\suml_{k=0}^\infty kc_kg(x)^{k-1}g'(x).$$
If $a_k=c_k g(x)^k$, $b_k=d(a_k)/dx=kc_kg(x)^{k-1}g'(x)$, $g(x)\not=0$, and $g'(x)\not=0$, then 
$$\left\lvert\frac{b_{k+1}}{b_k}\right\rvert
=\left\lvert\frac{(k+1)c_{k+1}g(x)^kg'(x)}{kc_kg(x)^{k-1}g'(x)}\right\rvert
=\frac{k+1}{k}\left\lvert\frac{c_{k+1}g(x)^k}{c_k g(x)^{k-1}}\right\rvert
=\frac{k+1}{k}\left\lvert\frac{c_{k+1}g(x)^{k+1}}{c_k g(x)^k}\right\rvert
=\left(1+\frac{1}{k}\right)\left\lvert\frac{a_{k+1}}{a_k}\right\rvert.$$
Therefore, 
$$\liml_{k\rightarrow\infty}\left\lvert\frac{b_{k+1}}{b_k}\right\rvert=\liml_{k\rightarrow\infty}\left(1+\frac{1}{k}\right)\liml_{k\rightarrow\infty}\left\lvert\frac{a_{k+1}}{a_k}\right\rvert=1\cdot\liml_{k\rightarrow\infty}\left\lvert\frac{a_{k+1}}{a_k}\right\rvert<1.$$
Thus, the ratio-test limit is not changed by the term-by-term differentiation,
except where $g(x)=0$ or $g'(x)=0$.
Since the ratio-test limit 
$\liml_{k\rightarrow\infty}\left\lvert\frac{a_{k+1}}{a_k}\right\rvert$ for 
for $f(x)$ is $<1$ for all $x$ in $I$ where $g(x)\not=0$, 
the ratio-test limit 
$\liml_{k\rightarrow\infty}\left\lvert\frac{b_{k+1}}{b_k}\right\rvert$ for 
for $S(x)$ is $<1$ for all $x$ in $I$ where $g(x)\not=0$ and $g'(x)\not=0$;
where $g(x)=0$ or $g'(x)=0$, $0=b_2=b_3=b_4=b_5=\cdots$.
Hence, $S(x)$ converges for all $x$ in $I$.

It remains to show that $f'(x)$ exists and equals $S(x)$ for all $x$ in $I$.
Fix $a$ in $I$.
For all $x$ in $I$, we have
$S(x)=\frac{d}{dx}\intl_a^x S(t)\dd t$ (section 4.2, \cite{keisler}),
if $\intl_a^x S(t)\dd t$ exists for all $x$ in $I$.
So, it suffices to show that $\intl_a^x S(t)\dd t$ exists 
and equals $f(x)-f(a)$ for all $x$ in $I$,
for this implies $S(x)=\frac{d}{dx}(f(x)-f(a))=f'(x)$.

We can express 
$b_k$ as $kc_k(p(x)^k-q(x)^k)$ 
where $p$ and $q$ are the $k$th roots of 
the ``positive and negative parts'' of $g^{k-1}g'$, respectively.
More precisely, $p(x)=\sqrt[k]{\max(0,g(x)^{k-1}g'(x))}$
and $q(x)=\sqrt[k]{\max(0,-g(x)^{k-1}g'(x))}$.
The maximum of any two continuous functions is continuous
(the proof is left as an exercise for the reader),
and the two maxima defined above are always nonnegative,
so $p$ and $q$ are continuous on $I$.
For any value of $x$, $g(x)^{k-1}g'(x)\geq 0$, in which case
$q(x)=0$, or $g(x)^{k-1}g'(x)\leq 0$, in which case
$p(x)=0$.  
Therefore, for all $x$ in $I$, either
$S(x)=\suml_{k=0}^\infty b_k=\suml_{k=0}^\infty kc_kp(x)^k$
and $q(x)=0$, or
$S(x)=\suml_{k=0}^\infty b_k=\suml_{k=0}^\infty -kc_kq(x)^k$
and $p(x)=0$.

Hence, for all $x$ in $I$, either the ratio-test limit for
$\suml_{k=0}^\infty kc_kp(x)^k$ is $<1$, or $p(x)=0$.
Therefore, Theorem 1 applies to $\suml_{k=0}^\infty kc_kp(t)^k$.
Likewise, Theorem 1 applies to $\suml_{k=0}^\infty -kc_kq(t)^k$.
So, applying Theorem 1 in the second equation below, 
\begin{align*}
\intl_a^x S(t)\dd t
&=\intl_a^x\left(\suml_{k=0}^\infty kc_kp(t)^k\right)\dd t
+\intl_a^x\left(\suml_{k=0}^\infty -kc_kq(t)^k\right)\dd t\\
&=\suml_{k=0}^\infty\left(\intl_a^x kc_kp(t)^k\dd t\right)
+\suml_{k=0}^\infty\left(\intl_a^x -kc_kq(t)^k\dd t\right)\\
&=\suml_{k=0}^\infty\left(\intl_a^x kc_kp(t)^k\dd t+\intl_a^x -kc_kq(t)^k\dd t\right)\\
&=\suml_{k=0}^\infty\left(c_k\intl_a^x k(p(t)^k-q(t)^k)\dd t\right)\\
&=\suml_{k=0}^\infty\left(c_k\intl_a^x kg(t)^{k-1}g'(t)\dd t\right)
=\suml_{k=0}^\infty\left(c_k\intl_{g(a)}^{g(x)} k u^{k-1}\dd u\right)\\
&=\suml_{k=0}^\infty c_k\left(\left.u^k\right\rvert_{g(a)}^{g(x)}\right)
=\suml_{k=0}^\infty c_k(g(x)^k-g(a)^k)
=\suml_{k=0}^\infty c_kg(x)^k-\suml_{k=0}^\infty c_kg(a)^k\\
&=f(x)-f(a).
\end{align*}
Thus, $\intl_a^x S(t)\dd t=f(x)-f(a)$ as desired; the proof is complete.
\end{proof}

\begin{thebibliography}{9}

\bibitem{keisler} Keisler, H. Jerome, {\it Elementary Calculus, an Infinitesimal Approach}, 
http://www.math.wisc.edu/$\sim$keisler/calc.html, 
revised December 2010.
\end{thebibliography}

\end{document}
