Plotting zeros of functions: 
Steven J Miller: sjm1@williams.edu

Goal is to show how to plot the complex zeros of a sequences of functions. The first program plots the zeros
of x^n  -  n^n =  0, so the n-th complex roots of unity multiplied by n. We can see points emerging, we can
see them expanding to infinity. For the code, we append to a list and then use manipulate to choose what
list element we display; note as the list has disjoint elements we need to use the Floor function.

allzeros = {};
For[n = 1, n <= 100, n++,
{
zeros = {};
For[j = 1, j <= n, j++, zeros = AppendTo[zeros, {Re[n Exp[2.0 Pi I j / n]], Im[n Exp[2.0 Pi I j / n]]}]];
allzeros = AppendTo[allzeros, zeros]
}]
Manipulate[ListPlot[allzeros[[Floor[n]]]], {n,1,100}]

The code below is a test to make sure we know how to find roots and print. 
We are approximating exp(x) with the degree n Taylor series. Note this has n zeros, but exp(x) has no zeros!
Where do the zeros go? That’s what we’re trying to see with this code. We use NSolve to find the zeros,
but they are displayed as a list and we need to remove the “x” so we can store properly - that’s what x /. does.
We then plot a few things to show the issues with numerical stability as to how well can this function / roots be found.
In particular, do we really think there are THIS many real zeros?

expapprox[x_,n_] := Sum[x^k/k!, {k,0,n}]
listroots =x /.NSolve[expapprox[x,60] == 0, x] 
Length[listroots]
ComplexListPlot[listroots]
Plot[expapprox[x,60], {x,-18, -16}]
Plot[expapprox[x,60], {x,-17.72, -17.68}]

The code here plots the zeros of the n-th Taylor approximation of exp(z).
Doing slightly differently than before - saving it as an array not a list.
As it takes awhile to run as the degree grows, it prints out how far we’ve gone.

max = 60;
expapprox[x_,n_] := Sum[x^k/k!, {k,0,n}]
(*listroots =x /.NSolve[expapprox[x,100] == 0, x] *)
Clear[listroots];
For[n = 1, n <= max, n++,
{
If[Mod[n,10] == 0, Print["We are at n = ", n, " and have done ", 100. n / max, "%."]];
zeros = {};
For[j = 1, j <= n, j++, 
{
listroots[n]=  x /.NSolve[expapprox[x,n] == 0.0, x] 
}]; (* end of j loop *)
}];
Print[Manipulate[ComplexListPlot[listroots[Floor[n]] ], {n,1,max} ]]