# Homework Help: Can someone figure out the formula of this sequence?

1. Oct 20, 2017

### yellowcakepie

I needed help figuring out the formula for a sequence with these conditions:
1. The first term is 1.
2. All terms are positive integers.
3. 3 times each term (3*a_n) must be greater than the sum of that term and all the terms before it, but no more than 3 greater.

Operators like ceil() and floor() are probably needed, but I'm not certain.

Last edited by a moderator: Oct 20, 2017
2. Oct 20, 2017

### Staff: Mentor

Did you find some elements manually? That will give an idea how a general formula might look like.

http://oeis.org can help as well if you have some elements.

Edit: I moved the thread to our homework section.

Last edited: Oct 21, 2017
3. Oct 20, 2017

### arivero

I think you are wrong in this point, note that there are no floats here, and you are not asking for an approximation.
so perhaps you are confused because you are looking how to use them... I mean, you can always use conditionals or so.

4. Oct 20, 2017

### yellowcakepie

Yeah, I know a few terms of it.

1, 1, 2, 3, 4, 6, 10

On OEIS, it seems like this formula follows A130126, which seems quite complicated.

sqrt(Pi^2/2 + 4*log(phi)^2) * exp(sqrt((Pi^2 + 8*log(phi)^2)*(n/2))) / (4*Pi*n)
where phi is the golden ratio (1+sqrt(5))/2.

I'll check on this later. Thank you!

5. Oct 20, 2017

### arivero

I still do not get your condition,
"3 times each term (3*a_n) must be greater than the sum of that term and all the terms before it", ok
3 a_n > a_1+... + a_n
"but no more than 3 greater."
?? What does that mean? 3 (a_1+...+a_n) > 3 a_n ?

6. Oct 20, 2017

### yellowcakepie

That means a_n must be the smallest integer possible where 3*a_n is still greater than ∑a_i from i=1 to i=n. So 3 >= 3*a_n - ∑a_i from i=1 to i=n > 0.
Sorry, I don't know how to format on this forum...

Using the sequence I wrote above, we can test it and use it as an example:
a_7 = 10. That means 3*a_7 = 30. It must be greater than the sum of itself and all the terms before it, but no more than 3 greater.

30 - (1 + 1 + 2 + 3 + 4 + 6 + 10) = 30 - (27) = 3, which is less than or equal to 3, so it is the only correct term for a_7. It cannot be any other number.

7. Oct 20, 2017

### Staff: Mentor

Do you have to find an explicit formula (you have one, it is just messy) or is a recursive formula sufficient?

8. Oct 20, 2017

### StoneTemplePython

maybe solve a simpler problem first?

$3 a_n \gt \sum_{i=1}^n a_i$

can be more simply written as

$2 a_n \gt \sum_{i=1}^{n-1} a_i$

For example: the simpler problem would be: $a_n \gt \sum_{i=1}^{n-1} a_i$

This suggests a sequence of doubling.

e.g. 1, 2, 4, 8, 16, 32...

9. Oct 20, 2017

### yellowcakepie

I plugged the explicit formula into a sequence plotter, but every term is a noninteger, and does not match my calculations for the first 7 terms. Very strange.

A recursive formula is okay as well.

10. Oct 24, 2017

### Staff: Mentor

That is much easier to find. If you have the first n values, can you write an equation including the next one? Or maybe inequalities first?

11. Oct 24, 2017

### yellowcakepie

I think I already found it, but it's a little inconsistent.

a(n) = 1.5(a(n-1)-a(n-2)) + a(n-1)

Sometimes it is a decimal, 1 too high, or 1 too low.

12. Oct 25, 2017

### rcgldr

I get a different sequence, for example, 9 is the smallest number where 3x9 > sum {1,1,2,3,4,6,9}.

Code (Text):

sequence: 1   1   2   3   4   6   9  14  21  31  47  70 105 158 237
sum:      1   2   4   7  11  17  26  40  61  92 139 209 314 472 709

There's a formula for the sum. I don't know if this could be converted into a formula for the sequence.

Code (Text):

sum[i] = 1+⌊3(sum[i-1])/2⌋
seq[i] = sum[i]-sum[i-1]

Last edited: Oct 25, 2017
13. Oct 25, 2017

### Ray Vickson

People have asked you about the following, but you have refused to answer. Does the second condition mean
$$\text{(1) this:}\;\;\; 3a_n \leq \sum_{i=1}^n a_i + 3$$
or
$$\text{(2) this:} \;\; 3 a_n \leq 3 \sum_{i=1}^n a_i?$$
Just tell us if it is (1) or (2).

14. Oct 25, 2017

### rcgldr

I suggest changing the third condition to the smallest integer $a_n$ such that
$$3\ a_n \gt \sum_{i=1}^n a_i$$
or to "no more than 2 greater":
$$\sum_{i=1}^n a_i \lt \ 3\ a_n \le 2 \ + \ \sum_{i=1}^n a_i$$
Either of these conditions will produce the same sequence, and this eliminates the issue where the 7th term could be either 9 or 10.

Last edited: Oct 25, 2017
15. Oct 26, 2017

### yellowcakepie

Yeah, the sequence you made is correct. I screwed up some arithmetic when I was just trying to write my reply.

16. Oct 26, 2017

### yellowcakepie

(1), I think I answered that question a while ago with a reply to someone else.

17. Oct 26, 2017

### rcgldr

Looks like there no way to avoid having some type of second variable in order to generate this series:

https://oeis.org/A005428

Maybe the original third condition where 3an is no more than 3 greater as opposed to no more than 2 greater allows a single variable formula to be used for a different series, although with the condition being no more than 3 greater allows for variations, such at the 7th element being either 9 or 10.

Last edited: Oct 26, 2017
18. Oct 29, 2017

### haruspex

Some observations...

Asymptotically, the ratio of consecutive terms must converge to 3/2.
It seems that for pairs in which the first is even the ratio is exact; where the first term is odd, it alternately rounds up and rounds down. E.g. 1 to 2 rounds up, 3 to 4 rounds down, 9 to 14 rounds up, 21 to 31 rounds down...
If that last observation could be characterised in terms of the value of the first of the pair (e.g. its value mod something) then the recurrence relation could be written without a summation.

Edit:
Looks like I have come close to characterising the rounding.
If a term is even, next term is exactly 3/2 times it, else
if it is 2, 3 or 5 mod 9 then round up, else
round down.
This works for the first 53 terms, but the 54th rounds the wrong way.

Curiously, no odd terms are 8 mod 9.

Last edited: Oct 29, 2017