2

I have this set of values and I am trying to find a pattern or function that links p and m. If I'm given the value of p, is there a formula that can generate m?

p   m
1   1
2   1
3   1
4   2
5   2
6   2
7   2
8   2
9   2
10  3
11  3
12  3
13  3
14  3
15  3
16  3
17  3
18  3
19  3
20  4
21  4
22  4
23  4
24  4
25  4
26  4
27  4
28  4
29  4
30  4
31  4
32  4
33  4
34  4
35  5
36  5
37  5
38  5
39  5
40  5
41  5
42  5
43  5
44  5
45  5
46  5
47  5
48  5
49  5
50  5
51  5
52  5
53  5
54  5
55  5
56  6
57  6
58  6
59  6
60  6
61  6
62  6
63  6
64  6
65  6
66  6
67  6
68  6
69  6
70  6
71  6
72  6
73  6
74  6
75  6
76  6
77  6
78  6
79  6
80  6
81  6
82  6
83  6
84  7
85  7
86  7
87  7
88  7
89  7
90  7
91  7
92  7
93  7
94  7
95  7
96  7
97  7
98  7
99  7
100 7
101 7
102 7
103 7
104 7
105 7
106 7
107 7
108 7
109 7
110 7
111 7
112 7
113 7
114 7
115 7
116 7
117 7
118 7
119 7

Here's what I've observed. There are 3 numbers (1-3) that produce 1, 6 numbers(4 - 9) that produce 2, 10 numbers (10 - 19), that produce 3, 15 numbers (20 - 34) that produce 4, 21 numbers (35-55) that produce 5 and so on so forth. So basically, the size of each group of numbers is increasing by triangular numbers n(n + 1) / 2. I've been thinking about it for a few hours but I can't formulate a formula that will calculate m if I'm provided with the value of p.

For more context and background to this problem, I am studying tetrahedral numbers and the value p is just any randomly selected positive integer, and the value of m is the length of a list of tetrahedral numbers ( https://www.geeksforgeeks.org/tetrahedral-numbers/ ) smaller than p. For example, when p = 5, the list of tetrahedral numbers smaller than 5 is {1, 4} and the size of that list, m = 2. When p = 40, the list = {1, 4, 10, 20, 35} and the size of that list, m = 5.

Mees de Vries
  • 26,947
Kaylo
  • 123
  • Hi! Welcome to MSE! Have you tried searching your sequence here: http://oeis.org ? – Chain Markov Apr 15 '19 at 21:24
  • Indeed, the sequence of tetrahedral numbers https://oeis.org/A000292 may be relevant – Bolton Bailey Apr 15 '19 at 22:06
  • Hey, thank you.

    Yeah, I'm able to generate a sequence of tetrahedral numbers (and I have implemented an algorithm to do so in Java.) I'm also able to generate a sequence of tetrahedral numbers smaller than any value n. What I want to do is to be able to calculate the length of any sequence of tetrahedral numbers from 1...t, where t is smaller than some value, n.

    – Kaylo Apr 15 '19 at 22:31

2 Answers2

1

I found an approximate answer. $${\left\lfloor \frac{1}{2} (2 \sqrt{144x^2+36x-29} + 24x + 3)^{\frac{1}{3}} - \frac{3}{2}\right\rceil}$$ Basically, I did the following. I found the number of triangular numbers summed together up to $x$. $$\int_{1}^x \frac{t(t+1)}{2} dt + \frac{x(x+1)}{2}$$ Because the $+C$ from the integration is approximately $-.5$, it becomes the following. $$\frac{2x^3+9x^2+6x-6}{12}$$ This is the inverse of the actual sum, so I had Wolfram do a literal equation solve where I switched $x$ and $y$ and I got the equation in the answer. The output equation had some remainder of $5$ divided by a function of $x$, which tends to $0$ so I disregarded it. Sorry if it's messy, but this is the way that came to mind.

Photo of the two functions. Green is actual and red is this function.

Théophile
  • 24,627
Ryan Shesler
  • 1,498
  • What does it mean to have a ceiling on the left and a floor on the right? I'm trying to translate this function to java. – Kaylo Apr 16 '19 at 00:48
  • I just meant round. Sorry, on a chalkboard or something I would write round() but I’m not 100% familiar with latex/mathjax yet. – Ryan Shesler Apr 16 '19 at 00:52
0

Well, we have that the sum of the first $n$ triangular numbers is $$\sum_{k = 1}^n \frac{n(n+1)}{2} = \frac{1}{2}\sum_{k=1}^n (n^2 + n) = \frac{1}{2}\left(\frac{n(n+1)}{2} + \frac{n(n+1)(2n+1)}{6} \right) = \frac{n(n+1)(n+2)}{6}$$

Basically, given $p$, we want to find the greatest $n$ such that $\frac{n(n+1)(2n+1)}{6}$ is $\leq p$; This gives us $$m = \left[ \text{Real root of } x(x+1)(x+2) = 6p \right],$$ where $[x]$ denotes the integer part of $x$. Solving explicitely for $x$ gives a closed-form formula.

Wolfram gives $$m = \left[ \frac{\sqrt[3]{ \sqrt{3} \sqrt{243p^2 - 1} + 27p}}{3^{2/3}} + \frac{1}{\sqrt[3]{3}\sqrt[3]{ \sqrt{3} \sqrt{243p^2 - 1} + 27p}} - 1\right]$$

Tanny Sieben
  • 2,471