Hooray! We made it. You did a great job making it through the whole arc of number theory accessible at the undergraduate level.
And we really did see a lot of the problems out there, including solving them. Here are some that we did not see all the way through, though we were able to prove some things about them.
It's this last one that I want to focus on today. Recall Gauss' estimate for $\pi(x)$, the logarithmic integral function.
Click to the left again to hide and once more to show the dynamic interactive window 
It wasn't too bad. But we were hoping we could get a little closer. So, among several other things, we tried $$Li(x)\frac{1}{2}Li(\sqrt{x})\; .$$ And this was indeed better.
Click to the left again to hide and once more to show the dynamic interactive window 
So one might think one could keep adding and subtracting $$\frac{1}{n}Li(x^{1/n})$$ to get even closer, with this start to the pattern.
As it turns out, that is not quite the right pattern. In fact, the minus sign comes from $\mu(2)$, not from $(1)^{2+1}$, as usually is the case in series like this!
Click to the left again to hide and once more to show the dynamic interactive window 
However, it should be just as plain that this approximation doesn't really add a lot beyond $k=3$. In fact, at $x=1000000$, just going through $k=3$ gets you within one of $\sum_{j=1}^\infty\frac{\mu(j)}{j}Li(x^{1/j})$. So this is not enough to get a computable, exact formula for $\pi(x)$.
Questions this might raise:
We will answer these questions in this last lecture.
Click to the left again to hide and once more to show the dynamic interactive window 
This table shows the errors in Gauss' and our new estimates for every hundred thousand up to a million. Clearly Gauss is not exact, but the other error is not always perfect either.
After the PNT was proved, mathematicians wanted to get a better handle on the error in the PNT. In particular, the Swedish mathematician Von Koch made a very interesting contribution in 1901.
Conjecture: The error in the PNT is less than $$\frac{1}{8\pi}\sqrt{x}\ln(x)\; .$$
This seems to work, broadly speaking.
Click to the left again to hide and once more to show the dynamic interactive window 
Given this data, the conjecture seems plausible, if not even improvable (though remember that $Li$ and $\pi$ switch places infinitely often!). Of course, a conjecture is not a theorem. He did have one, though.
Theorem: The error estimate above is equivalent to saying that $\zeta(s)$ equals zero precisely where Riemann thought it would be zero in 1859.
This may seem odd. After all, $\zeta$ is just about reciprocals of all numbers, and can't directly measure primes. But in fact, the original proofs of the PNT also used the $zeta$ function in essential ways. So Von Koch was just formalizing the exact estimate it could give us on the error.
Indeed, Riemann was after bigger fish. He didn't just want an error term. He wanted an exact formula for $\pi(x)$, one that could be computed  by hand, or by machine, if such a machine came along  as close as one pleased. And this is where $\zeta(s)$ becomes important, because of the Euler product formula: $$\sum_{n=1}^{\infty} \frac{1}{n^s}=\prod_{p}\frac{1}{1p^{s}}$$
Somehow $\zeta$ does encode everything we want to know about prime numbers. And Riemann's paper, "On the Number of Primes Less Than a Given Magnitude", is the place where this magic really does happen, and seeing just how it happens is our goal to close the course.
We'll begin by plotting $\zeta$, to see what's going on.

As you can see, $\zeta(s)$ doesn't seem to hit zero very often. Maybe for negative $s$...
Wait a minute! What is this plot? Shouldn't $\zeta$ diverge if you put negative numbers in for $s$? After all, then we'd get things like $$\sum_{i=1}^\infty n$$ for $s=1$, and somehow I don't think that converges.

In fact, it turns out that we can evaluate $\zeta(s)$ for nearly any complex number $s$ we desire. The graphic above colorcodes where each complex number lands by matching it to the color in the second graphic.
The important point isn't the picture itself, but that there is a picture. Yes, $\zeta$ can be defined for (nearly) any complex number as input.
One way to see this is by looking at each term $\frac{1}{n^s}$ in $\zeta(s)=\sum_{n=1}^\infty \frac{1}{n^s}$. If we let $s=\sigma+it$ (a longstanding convention, instead of $x+iy$), we can rewrite $$n^{s}=e^{s\ln(n)}=e^{(\sigma+it)\ln(n)}=e^{\sigma\ln(n)}e^{it\ln(n)}=n^{\sigma}\left(\cos(t\ln(n))i\sin(t\ln(n))\right)$$ where the last step comes from something you may remember from calculus, and that is very easy to prove with Taylor series  that $$e^{ix}=\cos(x)+i\sin(x)\; .$$
So at least if $\sigma>1$, since $\cos$ and $\sin$ always have absolute value less than or equal to one, we still have the same convergence properties as with regular series, if we take the imaginary and real parts separately  $$\sum_{n=1}^\infty\frac{\cos(t\ln(n))}{n^s}+i\sum_{n=1}^\infty\frac{\sin(t\ln(n))}{n^s}$$
That doesn't explain the part of the complex plane on the left of the picture above, and all I will say is that it is possible to do this, and Riemann did it. (In fact, Riemann also is largely responsible for much of advanced complex analysis.)
Let's get a sense for what the $\zeta$ function looks like. First, a threedimensional plot of its absolute value for $\sigma$ between 0 and 1 (which will turn out to be all that is important for our purposes).

To get a better idea of what happens, we look at the absolute value of $\zeta$ for different inputs. Here, we look at $\zeta(\sigma+it)$, where $\sigma$ is the real part, chosen by you, and then we plot $t$ out as far as requested. Opposite that is the line which we are viewing on the complex plane.
Click to the left again to hide and once more to show the dynamic interactive window 
You'll notice that the only places the function has absolute value zero (which means the only places it hits zero) are when $\sigma=1/2$.
Another (very famous) image is that of the parametric graph of each vertical line in the complex plane as mapped to the complex plane. You can think of this as where an infinitely thin slice of the complex plane is 'wrapped' to.
Click to the left again to hide and once more to show the dynamic interactive window 
The reason this image is so famous is because the only time it seems to hit the origin at all is precisely at $\sigma=1/2$  and there, it hits it lots of times. Everywhere else it just misses, somehow.
That is not one hundred percent true, because it is also zero at negative even integer input, but these are well understood; this is the mysterious part. And so we have the
Riemann Hypothesis:
$$\text{ All the zeros of }\zeta(s)=\zeta(\sigma+it)\text{ where }t\neq 0\text{ are on }\sigma=1/2\; .$$
The importance of this problem is evidenced by it having been selected as one of the seven Millennium Prize problems by the Clay Math Institute (each holding a milliondollar award), as well as having no fewer than three recent popular books devoted to it (including the best one from our mathematical perspective, Prime Obsession by John Derbyshire).
The rest of our time is dedicated to seeing why this might be related to the distribution of prime numbers, such as Von Koch's result showing the RH is equivalent to a bound on the error $\left\pi(x)Li(x)\right$.
We'll pursue this in three steps.


The function above is one Riemann called $f$, but which we (following Edwards and Derbyshire) will call $J(x)$. It is very similar to $\pi(x)$ in its definition, so it's not surprising that it looks similar.
$$J(x)=\pi(x)+\frac{1}{2}\pi(\sqrt{x})+\frac{1}{3}\pi(\sqrt[3]{x})+\frac{1}{4}\pi(\sqrt[4]{x})+\cdots=\sum_{k=1}^\infty \frac{1}{n}\pi\left(x^{1/n}\right)$$
This looks like it's infinite, but it's not actually infinite. For instance, we can see on the graph that $$J(20)=\pi(20)+\frac{1}{2}\pi(\sqrt{20})+\frac{1}{3}\pi(\sqrt[3]{20})+\frac{1}{4}\pi(\sqrt[4]{20})=8+\frac{2}{2}+\frac{1}{3}+\frac{1}{4}=9\frac{7}{12}$$ because $\sqrt[5]{20}\approx 1.8$ and $\pi(\sqrt[5]{20})\approx\pi(1.8)=0$, so the sum ends there.
Okay, so we have this new function. Yet another arithmetic function. So what?
Ah, but what have we been doing to all our arithmetic functions to see what they can do, to get formulas for them? We've been Moebius inverting them, naturally! In this case, Moebius inversion could be really great, since it would give us something about the thing being added  namely, $\pi(x)$.
The only thing standing in our way is that $$J(x)=\sum_{k=1}^\infty \frac{1}{n}\pi\left(x^{1/n}\right)$$ which is not a sum over divisors. But it turns out that, just like when we took the limits of the sum over divisors $\sum_{d\mid n}\frac{1}{d}$, we got $\sum_{n=1}^\infty \frac{1}{n}$, we can do the same thing with Moebius inversion.
Fact:
If $\sum_{n=1}^\infty f(x/n)$ and $\sum_{n=1}^\infty g(x/n)$ both converge absolutely, then $$g(x)=\sum_{n=1}^\infty f(x/n)\Longleftrightarrow f(x)=\sum_{n=1}^\infty \mu(n)g(x/n)\; .$$
For us, we've just defined $g=J$ with $f(x/n)=\frac{1}{n}\pi\left(x^{1/n}\right)$, and so we get the very important result that $$\pi(x)=\sum_{n=1}^\infty \mu(n)\frac{J(x^{1/n})}{n}=J(x)\frac{1}{2}J(\sqrt{x})\frac{1}{3}J(\sqrt[3]{x})\frac{1}{5}J(\sqrt[5]{x})+\frac{1}{6}J(\sqrt[6]{x})+\cdots$$
(If that last use of Moebius inversion looked a little sketchy, it does to me too, but I cannot find a single source where it's complained about that $f(x/n)=\frac{1}{n}\pi\left(x^{1/n}\right)$ is really a function of $x$ and $n$, not just $x/n$. In any case, the result is correct, via a somewhat different explanation of this version of inversion in a footnote in Edwards.)
Now, this looks just as hopeless as before. How is $J$ going to help us calculate $\pi$, if we can only calculate $J$ in terms of $\pi$ anyway?
Ah, but here is where Riemann "turns the Golden Key", as Derbyshire puts it.

We can see above that this has the potential to be a very good approximation, even given that I did limited calculations here. The most interesting thing is the gentle waves you should see; this is quite different from the other types of approximations we had, and seems to have the potential to mimic the more abrupt nature of the actual $\pi(x)$ function much better in the long run.
So let's see what this is. First, let's connect $J$ and $\zeta$.
Recall the Euler product for $\zeta$ again: $$\zeta(s)=\prod_{p}\frac{1}{1p^{s}}$$
The trick to getting information about primes out of this, as well as connecting to $J$, is to take the logarithm of the whole thing. This will turn the product into a sum  something we can work with much more easily: $$\ln(\zeta(s))=\sum_{p}\ln\left(\frac{1}{1p^{s}}\right)=\sum_{p}\ln\left(1p^{s}\right)$$
If we just had the fraction, we could use the geometric series to turn this into a sum (in fact, that is where it came from), but we got rid of it.
Question: So what can we do with $\ln()$ of some sum, not a product?
Answer: We can use its Taylor series! $$\ln(1x)=\sum_{k=1}^\infty \frac{x^k}{k}$$
Plug it in: $$\ln(\zeta(s))=\sum_{p}\sum_{k=1}^\infty \frac{(p^{s})^k}{k}$$
Question: I don't see anything very useful here. Can I get anything good out of this?
Answer: Yes, in two big steps.
First, we rewrite $\frac{(p^{s})^k}{k}$ as an integral, so that we could add it up more easily.
Next, it would be nice to get this as one big integral. But of what function, and with what endpoints?
Hence $$\ln(\zeta(s))=s\sum_{p}\sum_{k=1}^\infty\int_{p^k}^\infty \frac{1}{k}x^{s1}dx=s\int_1^\infty J(x)x^{s1}dx$$ This completes our first of the final goals  connecting $\zeta$ and $J$.
[14.1347251, 21.0220396, 25.0108576, 30.4248761, 32.9350616, 37.5861782, 40.9187190, 43.3270733, 48.0051509, 49.7738325, 52.9703215, 56.4462477, 59.3470440, 60.8317785, 65.1125441, 67.0798105, 69.5464017, 72.0671577, 75.7046907, 77.1448401, 79.3373750, 82.9103808, 84.7354930, 87.4252746, 88.8091112, 92.4918993, 94.6513440, 95.8706342, 98.8311942] [14.1347251, 21.0220396, 25.0108576, 30.4248761, 32.9350616, 37.5861782, 40.9187190, 43.3270733, 48.0051509, 49.7738325, 52.9703215, 56.4462477, 59.3470440, 60.8317785, 65.1125441, 67.0798105, 69.5464017, 72.0671577, 75.7046907, 77.1448401, 79.3373750, 82.9103808, 84.7354930, 87.4252746, 88.8091112, 92.4918993, 94.6513440, 95.8706342, 98.8311942] 
We see all the zeros for $\sigma=1/2$ between $0$ and $100$; there are 29 of them.
Our next goal is to see how this connection $$\ln(\zeta(s))=s\int_1^\infty J(x)x^{s1}dx$$ relates to the zeros of the $\zeta$ function (and hence the Riemann Hypothesis).
We will do this by analogy  albeit a very powerful one, which Euler used to prove $\zeta(2)=\frac{\pi^2}{6}$ and which, correctly done, does yield the right answer.
Recall basic algebra. The Fundamental Theorem of Algebra states that every polynomial factors over the complex numbers. For instance, $$f(x)=5x^35x=5(x0)(x1)(x+1)\; .$$ So we could then say that $$\ln(f(x))=\ln(5)+\ln(x0)+\ln(x1)+\ln(x+1)$$ Then if it turned out that $\ln(f(x))$ was useful to us for some other reason, it would be reasonable to say that we can get information about that other material from adding up information about the zeros of $f$ (and the constant $5$), because of the addition of $\ln(xr)$ for all the roots $r$.
You can't really do this with arbitrary functions, of course, and $\zeta$ doesn't work  for instance, because $\zeta(1)$ diverges badly, no matter how you define the complex version of $\zeta$.
But it happens that $\zeta$ is very close to a function you can do that to, $(s1)\zeta(s)$. Applying the idea above to $(s1)\zeta(s)$ (and doing lots of relatively hard complex integrals, or some other formal business with difficult convergence considerations) allows us to essentially invert $$\ln(\zeta(s))=s\int_1^\infty J(x)x^{s1}dx$$ to $$J(x)=Li(x)\sum_{\rho}Li(x^\rho)\ln(2)+\int_x^\infty\frac{dt}{t(t^21)\ln(t)}$$
It is hard to overestimate the importance of this formula. Each piece comes from something inside $\zeta$ itself, inverted in this special way.
To give you a sense of how complicated this formula $$J(x)=Li(x)\sum_{\rho}Li(x^\rho)\ln(2)+\int_x^\infty\frac{dt}{t(t^21)\ln(t)}$$ really is, here is a plot of something related.

This is the plot of $$Li(20^{1/2+it})$$ up through the first zero of $\zeta$ above the real axis. It's beautiful, but also forbidding. After all, if takes that much twisting and turning to get to $Li$ of the first zero, what is in store if we have to add up over all infinitely many of them to calculate $J(20)$?
Now we are finally ready to see Riemann's result, by plugging in this formula for $J$ into the Moebius inverted formula for $\pi$ given by $$\pi(x)=J(x)\frac{1}{2}J(\sqrt{x})\frac{1}{3}J(\sqrt[3]{x})\frac{1}{5}J(\sqrt[5]{x})+\frac{1}{6}J(\sqrt[6]{x})+\cdots$$ Riemann did not prove it fully rigorously, and indeed one of the provers of the PNT mentioned taking decades to prove all the statements Riemann made in this one paper, just so he could prove the PNT. Nonetheless, it is certainly Riemann's formula for $\pi(x)$, and an amazing one:
$$\pi(x)=\sum_{n=1}^\infty \frac{\mu(n)}{n}\left[ Li(x^{1/n})\sum_{\rho}\left(Li(x^{\rho/n})+Li(x^{\bar{\rho}/n})\right)+\int_{x^{1/n}}^\infty\frac{dt}{t(t^21)\ln(t)}\right]$$
Two points:
Now let's see it in action.
Click to the left again to hide and once more to show the dynamic interactive window 
And this graphic shows just how good it can get. Again, notice the waviness, which allows it to approximate $\pi(x)$ not just once per 'step' of the function, but along the steps.
We can also just check out some numerical values.
mpf('62.169581705460772') 62 67.2884511014 62.1320949397 mpf('62.169581705460772') 62 67.2884511014 62.1320949397 
This is truly only the beginning of research in modern number theory.
For instance, research in finding points on curves leads to more complicated series like $\zeta$, called $L$functions. There is a version of the Riemann Hypothesis for them, too!
And it gives truly interesting, strange, and beautiful results  like the following result from the last year or two, with which we will end the course.
Let $r_{12}(n)$ denote the number of ways to write $n$ as a sum of twelve squares, like we did $r(n)$ the number of ways to write as a sum of two squares. Here, order and sign both matter, so $(1,2)$ and $(2,1)$ and $(2,1)$ are all different.
Theorem:
As we let $p$ go through the set of all prime numbers, the distribution of the fraction $$\frac{r_{12}(p)8(p^5+1)}{32p^{5/2}}$$ is precisely as $$\frac{2}{\pi}\sqrt{1t^2}$$ in the long run.

Click to the left again to hide and once more to show the dynamic interactive window 
Amazing!
This is based on the graphic below, kindly created for me by William Stein, the founder of Sage, whose research is directly related to such things.
Click to the left again to hide and once more to show the dynamic interactive window 
