# Formula to link two exponential values together - doesn't quite work

Basically, I've done a script, and I'm stuck on a formula for it. After I run the code on a cube, based on two different inputs (detail level and vertex average iterations), the resulting size will be different, and needs to be scaled upwards to fit normally again.

I've just wrote down the amounts it needs to be scaled by, in the hopes of making a formula that will calculate it, and automatically upscale it. So far, I have the first part, but the second part, which throws the other exponential values into it, doesn't seem to work with them all at once (I tried one but I presume each attempt will have the same result).

Here are the results I got, although it's not fully accurate as it was based on my judgement and what I expected. It is these values I need to figure out a formula for, so given detail level 1 and iteration of 7, it would result in slightly over 1.375.

Detail level of 0
0 = 1.2
1 = 1.45
2 = 1.65
3 = 1.8
4 = 1.9
5 = 1.95

Detail level of 1
0 = 1.1
1 = 1.2
2 = 1.285
3 = 1.35
4 = 1.375

Detail level of 2
0 = 1.05
1 = 1.1
2 = 1.125
3 = 1.137
4 = 1.144

Detail level of 3
0 = 1.025
1 = 1.035
2 = 1.054
3 = 1.06
4 = 1.07


So, to get the scale amount for any detail level with 0 vertex iterations, here is the way to do it, the output from this would be 1.2, 1.1, 1.05, etc, which matches the table perfectly.

Number to start with is 1.2
Run this for the number of detail levels selected:
New number = (old number - 1) ÷ 2 + 1


Then I wrote something based on the 2nd detail level to calculate the final result. It was obviously following an exponential pattern of (not sure how to put it in maths terms) +0.5 +0.25 +0.125 etc, so I believed it should then apply to the rest of the values. Unfortunately it did not, and gave drastically wrong results when trying with the other detail levels.

If I could have a little help finding something that would fit all the values I wrote above, or a better way of going about it, I'd be very grateful.

• Can you describe this in pseudocode/procedurally? Wading through code like this isn't necessarily second nature for your readers here. Jul 23, 2014 at 17:25
• Ah thanks for letting me know, I have attempted to simplify it a lot, is this better suited now? Jul 23, 2014 at 17:42

The numbers at each detail level are pretty close to square roots of numbers on the previous detail level. So, starting with Level $0$ (which you know how to compute) you can just take square roots. Works well except the last two entries at level 2; maybe they are off for some reason?

Here is the comparison of your numbers and square roots of numbers of preceding level.

Detail level of 1
0 = 1.1    vs   1.095
1 = 1.2    vs   1.204
2 = 1.285  vs   1.285
3 = 1.35   vs   1.342
4 = 1.375  vs   1.378

Detail level of 2
0 = 1.05    vs  1.047
1 = 1.1     vs  1.097
2 = 1.125   vs  1.133
3 = 1.137   vs  1.158
4 = 1.144   vs  1.174

Detail level of 3
0 = 1.025  vs  1.023
1 = 1.035  vs  1.048
2 = 1.054  vs  1.065
3 = 1.06   vs  1.076
4 = 1.07   vs  1.084


so given detail level 1 and iteration of 7, it would result in slightly over 1.375.

To check this, I'll guess that your table for level $0$ continues with

6 = 2
7 = 2
. = 2


Then for detail level $1$ and iteration of $7$ my prediction is $\sqrt{2}\approx 1.414$.