How to smoothly transition from start number to end number with a certain amount of numbers?

800 Views Asked by At

How would I transition from number to number smoothly, for example: Lets say I have a starting number of 3, and a ending number of 34 using only 8 numbers.

How would you make a formula to transition from 3 to 34 smoothly with 8 numbers like so:

3, 7, 12, 16, 21, 25, 29, 34

Or lets say we want have 15 numbers starting at 3 and ending at 34:

3, 5, 7, 10, 12, 14, 16, 18, 21, 23, 25, 27, 29, 32, 34

Would anyone know a mathematical formula for this that would work in Microsoft Excel?

I could not get close to any sort of formula nor could I find a formula for anything like this anywhere?

2

There are 2 best solutions below

0
On BEST ANSWER

I made the solution to work with @Rahul's formulas, I go it to work in excel so I made a python script that does this for anyone looking for the code.

start = 4
end = 34
amount_of_numbers = 9
step = (end - start)/(amount_of_numbers-1)
numbers = []
for i in range(amount_of_numbers):
    # In this case we want to start at 1, to simplify things.
    i = i + 1
    # first number
    if i == 1: numbers.append(start)
    # second number
    if i == 2: numbers.append(start+step)
    # everything in between
    if i >= 3 and i < amount_of_numbers: numbers.append(start + (i - 1) * step)
    # end
    if i == amount_of_numbers: numbers.append(start + (amount_of_numbers-1) * step)
for i, j in enumerate(numbers):
    i += 1
    print(str(i) + '. ' + str(j))

I know this isn't a programming forum but there might be students or people looking for code to do this, I hope this helps anyone looking for this in the future. :)

Thank you!

3
On

Let the count of numbers in your sequence be $n$, your start number be $a_1$ and your end number $a_n$. You could define your sequence by $$a_i = a_1 + \left\lfloor {i - 1 \over n - 1} (a_n - a_1) \right\rfloor $$ where the floor function, $\lfloor x \rfloor$, denotes the largest integer not greater than $x$, so your sequence is “biased” downward. You could also use the ceiling function $\lceil x\rceil$ which denotes the smallest integer not less than $x$, “biasing” your sequence upward.