03/14/2011, 05:33 PM

So I tried this out on the weekend to see what it looked like, and it works very well. Between addition and multiplication I used the "weighted arithmetic-geometric mean" that I described earlier in the post. Between multiplication and exponentiation I used a similar weighted function I call the "weighted exponential-geometric mean". Here is the C code; I lazily had it iterate 6 times instead of calling itself recursively and ending when the two means were close enough. I calculate m = a * b and n = a ^ b, I specify phi with some value between 1 and 2 and I call this function:

float wgxm(float m, float n, float phi)

{

int i;

float p,q;

phi--;

for (i=1;i<6;i++) {

p = pow(n/m,phi) * m;

q = pow(m, pow(log(n)/log(m),phi));

m = p;

n = q;

}

return p;

}

The attached graph shows the functions y = x {phi} 3, where phi varies from 0 to 2 by stepping 0.2. The light blue lines are at integer values of phi, i.e. y=x+3, y=3x and y=x^3. The yellow lines are the values calculated by the function above (and the corresponding one between addition and multiplication. The x axis goes from 1 to 20 and the y axis goes from 0 to 800. The grid lines are every unit in the x direction, and every 40 units in the y direction.

Something needs to be done to clean up the exponential/geometric interpolation function a little for it to work with values close to x=1 (the log of values close to 0 is negative). I don't think the formula works quite right whenever x^3 is smaller than x*3. The second attached graph is a close-up of the first, where x goes from 1 to 2 and y goes from 1 to 9, with gridlines in both directions every 0.25 (meaning the stretching/scaling is only by a factor of 2).

I'll have to see how the wgxm function looks if I interpolate between 3x and 3^x next, instead of x^3. Let me know if you think any of this looks nice.

float wgxm(float m, float n, float phi)

{

int i;

float p,q;

phi--;

for (i=1;i<6;i++) {

p = pow(n/m,phi) * m;

q = pow(m, pow(log(n)/log(m),phi));

m = p;

n = q;

}

return p;

}

The attached graph shows the functions y = x {phi} 3, where phi varies from 0 to 2 by stepping 0.2. The light blue lines are at integer values of phi, i.e. y=x+3, y=3x and y=x^3. The yellow lines are the values calculated by the function above (and the corresponding one between addition and multiplication. The x axis goes from 1 to 20 and the y axis goes from 0 to 800. The grid lines are every unit in the x direction, and every 40 units in the y direction.

Something needs to be done to clean up the exponential/geometric interpolation function a little for it to work with values close to x=1 (the log of values close to 0 is negative). I don't think the formula works quite right whenever x^3 is smaller than x*3. The second attached graph is a close-up of the first, where x goes from 1 to 2 and y goes from 1 to 9, with gridlines in both directions every 0.25 (meaning the stretching/scaling is only by a factor of 2).

I'll have to see how the wgxm function looks if I interpolate between 3x and 3^x next, instead of x^3. Let me know if you think any of this looks nice.

(03/11/2011, 06:12 PM)JmsNxn Wrote:(03/11/2011, 12:35 AM)lloyd Wrote: Surely, though, {0.25} should be weighted 3/4s towards the arithmetic mean, and 1/4 towards the geometric mean. Ah but is the weighting carried out arithmetically or geometrically? Apply a 3/4 arithmetic : 1/4 geometric weighting there too! And take the limiting case again.

In other words, for a {0.25} b, with a<b,

m1 of a and b = a + (b-a)*0.25 (0.25 of the way between a and b, judged arithmetically)

m2 of a and b = a * (b/a)^0.25 (0.25 of the way between a and b, judged geometrically)

Now plug m1 and m2 into a and b, and iterate until you get something stable (i.e. m1 = m2 to whatever degree of precision you need)

This seems like a good generalisation to real values between 0 and 1!

Yes! I like that a lot.