Solving for 3 variables (formula x=a + (b * (b - 1) / 2))

Dan W

New member
Joined
Mar 26, 2023
Messages
5
I don't know if this is not solvable by math, and if not I am sorry to have wasted your time.

I have this formula:
x=a + (b * (b - 1) / 2)

and I know these facts: all numbers are integers, a & b are in the range 0-63, and a < b.

Using the above formula, I get a x as a unique number between 0 and 2015 for each (a,b) pair.

To solve for a & b for a given x I use this (from a computer program):

b = Truncate((0.5 + Sqrt(1 + (8 * x)) / 2))
a = x - (b * (b - 1) / 2)

So far so good.

I am trying to do the same with 3 variables a,b,c, and that is where the trouble starts.

I have the formula:
x=a + (b * (b - 1) / 2) +(c * (c - 1) * (c - 2)) / 6)

Which works fine for all tested sets from (0,1,2) -> (62,63,64). Verified with x between 0 and 41663.

How do I solve for a,b,c in this case ?
 
I don't know if this is not solvable by math, and if not I am sorry to have wasted your time.

I have this formula:
x=a + (b * (b - 1) / 2)

and I know these facts: all numbers are integers, a & b are in the range 0-63, and a < b.

Using the above formula, I get a x as a unique number between 0 and 2015 for each (a,b) pair.

To solve for a & b for a given x I use this (from a computer program):

b = Truncate((0.5 + Sqrt(1 + (8 * x)) / 2))
a = x - (b * (b - 1) / 2)

So far so good.

I am trying to do the same with 3 variables a,b,c, and that is where the trouble starts.

I have the formula:
x=a + (b * (b - 1) / 2) +(c * (c - 1) * (c - 2)) / 6)

Which works fine for all tested sets from (0,1,2) -> (62,63,64). Verified with x between 0 and 41663.

How do I solve for a,b,c in this case ?
Is x also an integer?
 
Looks like you are trying to index/enumerate all triplets (a,b,c) with a<b<c.
I'd try something similar to triangular roots, which you have used for the case of "duplets" (a,b). I.e. [imath]c=\lfloor t \rfloor[/imath], where [imath]t(t-1)(t-2) = x[/imath], but you have to solve a cubic equation for [imath]t[/imath] (instead of a quadratic one for the case of (a,b)). After that you find the triangular root [imath]b[/imath] of the remainder of [imath]x - c(c-1)(c-2)[/imath]/6, after which [imath]a=x-b(b-1)/2 - c(c-1)(c-2)/6[/imath].
 
I don't know if this is not solvable by math, and if not I am sorry to have wasted your time.

I have this formula:
x=a + (b * (b - 1) / 2)
b = Truncate((0.5 + Sqrt(1 + (8 * x)) / 2))
What happened to a when you solved for b??
 
Looks like you are trying to index/enumerate all triplets (a,b,c) with a<b<c.
I'd try something similar to triangular roots, which you have used for the case of "duplets" (a,b). I.e. [imath]c=\lfloor t \rfloor[/imath], where [imath]t(t-1)(t-2) = x[/imath], but you have to solve a cubic equation for [imath]t[/imath] (instead of a quadratic one for the case of (a,b)). After that you find the triangular root [imath]b[/imath] of the remainder of [imath]x - c(c-1)(c-2)[/imath]/6, after which [imath]a=x-b(b-1)/2 - c(c-1)(c-2)/6[/imath].
That is exactly what I am trying to do. Trying to encode/decode the triplets to remove an array of pre-computed values.
Unfortunately my background is in software development, not math.
I will have a look at the link, and see if that helps.
 
I did put that in the original message, just below b=Truncate(...) line.
Hi Dan. I think you misunderstood Steven's question.

The expression Sqrt(1 + 8x) is not correct because the radicand is missing an a-term. In other words, your solution for b is correct only when a=0. :)
[imath]\;[/imath]
 
Hi Dan. I think you misunderstood Steven's question.

The expression Sqrt(1 + 8x) is not correct because the radicand is missing an a-term. In other words, your solution for b is correct only when a=0. :)
[imath]\;[/imath]
You are right, I did misunderstand that, and from a pure math view, that is true.
However, given that I know that a<b and I always round down, no matter what a is, b will be the same value.
 
That is exactly what I am trying to do. Trying to encode/decode the triplets to remove an array of pre-computed values.
Unfortunately my background is in software development, not math.
I will have a look at the link, and see if that helps.
I will also have to look up Cardano's formula for cubic equations. Good luck.
 
Top