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
    @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