rss
Twitter Delicious Facebook Digg Stumbleupon Favorites

Sunday, October 9, 2011

A program to generate Harmonic Series


In mathematics, the harmonic series is the divergent infinite series:
\sum_{n=1}^\infty\,\frac{1}{n} \;\;=\;\; 1 \,+\, \frac{1}{2} \,+\, \frac{1}{3} \,+\, \frac{1}{4} \,+\, \frac{1}{5} \,+\, \cdots.\!
Its name derives from the concept of overtones, or harmonics in music: the wavelengths of the overtones of a vibrating string are 1/2, 1/3, 1/4, etc., of the string's fundamental wavelength. Every term of the series after the first is the harmonic mean of the neighboring terms; the term harmonic mean likewise derives from music.
The fact that the harmonic series diverges was first proven in the 14th century by Nicole Oresme, but this achievement fell into obscurity. Proofs were given in the 17th century by Pietro Mengoli,Johann Bernoulli, and Jakob Bernoulli.
Historically, harmonic sequences have had a certain popularity with architects. This was so particularly in the Baroque period, when architects used them to establish the proportions of floor plans, ofelevations, and to establish harmonic relationships between both interior and exterior architectural details of churches and palaces.
The harmonic series is counterintuitive to students first encountering it, because it is a divergent series though the limit of the nth term as n goes to infinity is zero. The divergence of the harmonic series is also the source of some apparent paradoxes. One example of these is the "worm on the rubber band". Suppose that a worm crawls along a 1 meter rubber band and, after each minute, the rubber band is uniformly stretched by an additional 1 meter. If the worm travels 1 centimeter per minute, will the worm ever reach the end of the rubber band? The answer, counterintuitively, is "yes", for after n minutes, the ratio of the distance travelled by the worm to the total length of the rubber band is
\frac{1}{100}\sum_{k=1}^n\frac{1}{k}.
Because the series gets arbitrarily large as n becomes larger, eventually this ratio must exceed 1, which implies that the worm reaches the end of the rubber band. The value of n at which this occurs must be extremely large, however, approximately e100, a number exceeding 1040. Although the harmonic series does diverge, it does so very slowly.
Another example is: given a collection of identical dominoes, it is clearly possible to stack them at the edge of a table so that they hang over the edge of the table. The counterintuitive result is that one can stack them in such a way as to make the overhang arbitrarily large, provided there are enough dominoes.

class Harmonic{
      public static void main(String args[]){
      int num = Integer.parseInt(args[0]);
      double result = 0.0;
      while(num > 0){
            result = result + (double) 1 / num;
            num--;
      }
      System.out.println("Output of Harmonic Series is "+result);
  }
}

1 comments:

Unknown said...

all the time ans is comming 1

Post a Comment

Powered by Blogger.