http://www.perlmonks.org?node_id=371791

chiburashka has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on (homework) Find Series from list of integers

Replies are listed 'Best First'.
Re: I give up
by castaway (Parson) on Jul 05, 2004 at 07:01 UTC
    You need to find the mathematical formula that creates the series, then implement it in Perl. This isn't really a perl question. (And smells of homework to me).

    C.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: I give up
by Limbic~Region (Chancellor) on Jul 05, 2004 at 19:18 UTC
    chiburashka,
    You might be able to cheat by having a look at the On-Line Encyclopedia of Integer Sequences. The problem with identifying the formula yourself is being able to constrain the possibilities. For instance does the next number depend on the previous number? To calculate the Nth number do all previous numbers up to N first? Is it linear or geometric?

    To say it a different way - having a handful of numbers and being told to find the formula that generated those numbers without any additional information is nearly impossible.

    Cheers - L~R

      Slight correction, the problem is not that you can't determine an equation that will generate the sequence; the problem is there are an infinite number of possibilities.

      Basically you need to define your criteria better. The only way to do this is to understand what is generating the sequence of numbers.
Re: I give up
by tachyon (Chancellor) on Jul 06, 2004 at 05:10 UTC

    So you have a sequence that may or may not be the numbers you show. You want a formula. Heard of graphs? You have an even number so they are not (all) primes. Even the simplest analysis of this sequence:

    8168300941723 0 8203756951684 -35456009961 8304283191943 -100526240259 8541534872809 -237251680866 8746833361583 -205298488774

    yields important information. ie it is not a linear sequence, nor is it a pure geometric progression. As you can see it increases by 3.5e10 1.0e11 2.3e11 BUT then only 2.0e11.

    cheers

    tachyon

Re: I give up
by husker (Chaplain) on Jul 06, 2004 at 14:12 UTC
    Talk to your math department. They are very familiar with ways to to do curve-fitting (which is what you are trying to do).

    Try this node which may be of interest to you. It will direct you to two online lectures about curve-fitting.

    Once you know the math, THEN you can do the coding. If you decide to implement your solution in Perl, come on back here if you give it a try and can't get it working. Be ready to show us the code you have written, and what errors or problems you are having with it. We are very willing to help those who have tried to help themselves first.