2
$\begingroup$

I'm primarily a programmer and am pretty rusty at math... so forgive me if this is a stupid question.

I have four number patterns as follows:

  • a) 3, 13, 31
  • b) 5, 17, 37
  • c) 7, 21, 43
  • d) 9, 25, 49

What are the functions to get any number (n) for equation (abcd)?

I know the pattern, and how to brute-force it, but I'm lost when it comes to knowing the exact formula to get, say, the 1000th value in the pattern. The pattern is very related in all the equations.

The pattern I know is this:

Every successive value increases by 8 more than the last value increased by, except for the first value which is increased by (7 + first value).

  • For instance, 3 in pattern 1 is increased by (7 + 3): 3 + 10 = 13
  • 13 is then increased by 8 more than 10: 13 + 18 = 31
  • 31 is then increased by 8 more than 18: 31 + 26 = 57 making a(4) = 57

Now how do I convert this knowledge into a function so that I don't have to write a programmatic loop every time I want to find x(n)?

  • 0
    Do you want the function itself or how to figure out how to get the function if, say the rules change a little?2011-08-31
  • 0
    Both preferably...2011-08-31
  • 1
    Since the function's second forward difference $\Delta^2 f$ is constant, $f(n)$ will be quadratic as $an^2+bn+c$. Write $f(n)=m$ for $n=1,2,3$ and $m$ the given values and you get a $3\times3$ linear system solvable with a simple matrix inversion.2011-08-31
  • 2
    There's not enough information. Where is the data from?2011-08-31
  • 0
    I feel that I've provided plenty of data. For the first number pattern the first 10 numbers are: 1, 3, 13, 31, 57, 91, 133, 183, 241, 307 I gave you the way *I* generate the numbers, using a programmatic loop that iterates `n` times.2011-08-31
  • 0
    There are infinitely many ways to continue it. See the [OEIS](http://oeis.org/) for some.2011-08-31
  • 0
    @Bill Oh I do like that site...thanks for pointing it out! But I disagree on the "infinitely many ways" I put in my 'first 10 numbers' that I posted in the previous comment and got 1 result. Although it looks like this is a search engine for number patterns, and not actually a calculator. Still useful :)2011-08-31
  • 0
    I can't edit my previous comment, but when i said the 'first 10 numbers' I accidentally prepended a '1', which I didn't mean to do.2011-08-31
  • 0
    Your data fits $a(n)=4n^2-2n+1$ starting from $n=2$2011-08-31
  • 0
    @nzifnab: I've modified my (incorrect) answer. Since it is wildly incorrect, I think it should be deleted. But I can't delete it since you've accepted it as most helpful. I suggest either: 1) unaccepting my answer and accepting the other answer since it is correct (I favor this one) or 2) if you really want me to keep my answer around because it was helpful, please comment as to that effect (but still you should probably switch acceptance to the other correct answer).2011-09-01

1 Answers 1

4

The first forward difference is defined by $\Delta f = f(n+1)-f(n)$. According to the intended pattern, this difference increases by $8$ every term. In the first instance, you get $$\Delta f (1)=13-3=10$$ $$\Delta f(2)=31-13=10+8.$$ It's easy to see that $\Delta f(3)=10+8+8$ and so on, so we get that $\Delta f(n)=2+8n$. Note also that $$\Delta f(1)+\Delta f(2)+\cdots+\Delta f(n-1)$$ is a telescoping sum which, after cancellation, evaluates to $f(n)-f(1)$. Hence $$f(n)=f(1)+\sum_{k=1}^{n-1}\Delta f(k)$$ $$=3+\sum_{k=1}^{n-1}(2+8k)$$ $$=3+2(n-1)+8\frac{(n-1)n}{2}$$ $$=4n^2-2n+1.$$ Above we used the formula for triangle number sums. This quadratic function agrees with the given values for $n=1,2,$ and $3$. This method can be applied to the other three patterns with

$$\Delta f_2(n)=4+8n, f_2(1)=5$$ $$\Delta f_3(n)=6+8n, f_3(1)=7$$ $$\Delta f_4(n)=8+8n, f_4(1)=9.$$

However, for the last pattern $f_4$, you should be able to see the terms as $3^2,5^2,7^2$ so that the general term is simply $f_4(n)=(2n+1)^2$.

  • 0
    Thanks for the excellent explanation :)2011-09-01