I once wrote a paper about zeros of polynomials (Interpolations Points and Zeros of Polynomials in Approximation Theory, Habilitation, 1993, KU Eichstätt). As a minor result the zeros of random polynomials were studied. I want to show you, how to plot the distribution of such polynomials in Euler Math Toolbox (EMT).
First we generate 10000 random polynomials of degree 20, compute their zeros, and collect all zeros in one long vector of 20000 complex numbers. The random polynomials have coefficients, which are 1-1-normal distributed.
>n=20; m=10000; >Z=zeros(m,n); loop 1 to m; Z[#]=polysolve(normal(n+1)+1); end; >z=flatten(Z);
This is of course a very special situation, causing the many zeros on the complex axis and the negative axis.
That is not the end of the story. If we clip off the large zeros, the distribution is very interesting.
>r=2; z=z[nonzeros(re(z)>-r && re(z)<r && im(z)>-r && im(z)<2)]; >plot2d(z,>points,style="."):
The theory in the mentioned paper tells us that the distribution goes towards the equal distribution on the unit circle if n tends to infinity.
Let us try to plot the density of the distribution with EMT. For this, we set up a vector of interval bounds, symmetric around the complex origin. Then we count the number of zeros in each square that is bounded by these real and complex interval ends. For this, we would need a two dimensional version of find(). Instead, we get the indices first and use a loop to count the number of points in each square of our rectangular pattern.
Then we can plot the density of the distribution with plotrgb().
>v=linspace(-2,2,101); >i=find(v,im(z))+1; j=find(v,re(z))+1; >N=zeros(cols(v),cols(v)); >loop 1 to cols(z); N[i[#],j[#]]=N[i[#],j[#]]+1; end; >Nc=1-scalematrix(N); >plot2d(none,-2,2,-2,2); plotrgb(rgb(Nc,Nc,Nc)):