How did scientists come to know that there exist millions of galaxies in the universe?

This is tough to calculate. Fortunately, we have a method to estimate this value. To do this, scientists can observe a region in the sky and count the number of galaxies (with the help of computers) in that region. This observed region is called as sample region. Scientists can then estimate the number of galaxies in the whole sky by multiplying the number of galaxies in the first case, with the number equivalent of how many such sample regions would fit in the entire sky. This method is called as Extrapolation. It is the process of estimating, beyond the original observation range, the value of a variable by its relationship with another variable.

Now, you would say that this value might be incorrect because all regions may not contain an equal number of galaxies. Yes, that might be true. Extrapolation allows us only to estimate. The preciseness of the value relies on the size of sampling region. And yes, the value is only valid for observable universe.

While estimates among different experts vary, an acceptable range is between 100 billion and 200 billion galaxies, Mario Livio, an astrophysicist at the Space Telescope Science Institute in Baltimore.

Also, you might be interested in reading this: NASA – Hubble Goes to the eXtreme to Assemble Farthest-Ever View of the Universe. The same method can also apply to find out the number of trees on the Earth or even finding the total number of runs that a team would make during a cricket match.

What is the frequency of Cosmic Rays?

Their name might deceive you but they actually do not share a part in the electromagnetic spectrum.

“The term ray is a historical accident, as cosmic rays were at first, and wrongly, thought to be mostly electromagnetic radiation. In common scientific usage, high-energy particles with intrinsic mass are known as “cosmic” rays, and photons, which are quanta of electromagnetic radiation (and so have no intrinsic mass) are known by their common names, such as “gamma rays” or “X-rays”, depending on their origin.”

They are high energy charged particles and travel at about the speed of light. They may contain particles with multiple energies and hence it is difficult to point out specific frequency for the cosmic rays. The frequency decreases with increasing energy of the particles.

“If you were to plot “cosmic rays” on an electromagnetic spectrum, it would basically encompass x-rays and everything higher in energy (higher in frequency or shorter in wavelength). I personally would leave it out, since I don’t think it’s a correct usage of “cosmic rays” (but I don’t make the rules).”
Dr. Eric Christian, NASA

So, the frequency at which cosmic rays must be operating would be anywhere more than 30EHz.