# Scale vector based on previous scaling

I’m writing peace of software that is able to uniformly scale set of vertices. To do that I have a buffer where I keep my vertices untouchable. When I need to resize them, I create copy of that buffer and multiply that copy by scaling matrix one time. And that -is repeated each time if I need to scale something! So I don’t want to make copy each time before scaling and I want to scale based on previous scale result.

I will describe my problem. Let say I have value 1 and I want it to become 100, so I will multiply it by 100 ONE time. But what if I need to achieve that same result (100) in some other arbitrary number of multiplications and get evenly distributed numbers. For example: number of steps = 4. So after each multiplication result must be increased by 100/4=25 (to produce 1,25,50,75,100 as a result). Multiplication sequence will look like this: 1*25*2*1.5*1.33. You will notice that this sequence will be different all the time depending on a number of steps! More than that if you want to go in opposite direction (to get this 100,75,50,25, 1), multiplication sequence is following: 100*0.75*0.666*0.5*0.04. What is the formula or algorithm for generating that sequences by taking known start value(x) and value(e), number of steps(n) and direction (from smaller to greater or from greater to smaller)? Any ideas how to solve this?

Besides, it’s very interesting that we get two different sequences depending on direction. I think this is why time goes in one direction for us ;)

## 1 Answer

If you want to get from $$1$$ to $$T$$ in $$n$$ steps stopping along the way at $$\frac{T}{n}, \frac{2T}{n}, \frac{3T}{n}, \ldots , \frac{nT}{n} = T$$ then the factors at each stage are the ratios of successive terms: $$\frac{2}{1}, \frac{3}{2}, \frac{4}{3}, \ldots, \frac{n}{n-1} .$$ This is your sequence $$2, \quad 1.5, \quad1.33.$$

You should be able to use a similar argument to find the sequence for going backwards.In your example it starts $$3/4, 2/3, 1/2$$.

• amazing! I will try it. Thank you) – oleg_phorostyna Mar 14 at 22:54
• It's not really so amazing when you think about it. If this answer works you can accept it (the checkmark) and upvote it. – Ethan Bolker Mar 14 at 23:01
• I'm still wondering how you manage to solve this? How you derive that formula? – oleg_phorostyna Mar 14 at 23:16
• The equally spaced landing points are $T/n$ apart. Two neighbors in the sequence are like $5T/n$ and $6T/n$. To get from the first of those to the second you multiply by $5/6$. – Ethan Bolker Mar 15 at 2:04
• Maybe i was tired and over complicate something that is very simple. But now i understand! If i have prev * x=next, than x=next/prev=((s+1) * (t/n)) / (s * (t/n))=(s+1) / s; where 's'- is multiplication step. To go in opposite direction - just swap - next * x=prev! I hope that during many multiplications (back and forward) precision will not be lost due to float arithmetic precision... – oleg_phorostyna Mar 15 at 8:55