by Mathnerd314 · 16y ago · 0 comments
if (x0<=0) y=0;
else
if (x0>=1) y=1;
else {
if ((2-3*x0)<=0) y=0;
else
if ((2-3*x0)>=1) y=1;
else {
if ((2-3*(2-3*x0))<=0) y=0;
else
if ((2-3*(2-3*x0))>=1) y=1;
else {
...
else {
y = (2-3*(2-3*(2-3*(2-3*(2-3*x0)))));
} } } } }
These can be solved for x0. if (x0<=0) y=0;
else
if (x0>=1) y=1;
else {
if ((2/3)<=x0) y=0;
else
if ((1/3)>=x0) y=1;
else {
if (x0<=(4/9)) y=0;
else
if (x0>=(5/9)) y=1;
else {
...
else {
y = (2-3*(2-3*(2-3*(2-3*(2-3*x0)))));
} } } } }
Obviously, because floating point arithmetic is not distributive or associative (or exact), the actual constants will be slightly different from 1/3, 2/3, etc.This performs an average of .004 subtractions and multiplications compared to my estimate of .988 for their algorithm.
Since this will probably not give strictly matching results for values close to 1/3, 2/3, 4/9, 5/9, etc., this is technically "super optimization" rather than supercompilation.
Are there any optimizers you know of that could get this far?
No comments yet.