I made a recent post about rational geometry, or a way to solve geometric problems with no need for trigonometric functions.
My intuition is that this new (apparently the Chinese invented it more than a thousand years ago) way of doing geometry can be very useful for machines.
I ran a very simple experiment. At the end of Chapter 1 from the referenced book, there is a simple geometric problem with the traditional solution and the rational solution.
I have implemented the solution in Java and run some measurements. The rational solution is x4 faster.
Note that the code requires Java 1.5, in order to access the new nanosecond timer.
The output is as follows:
java Geometry
3.313693059275397 computed in 200000ns
3.3136930592753853 computed in 23000ns
3.313693059275397 computed in 1046.7512ns
3.3136930592753853 computed in 250.1114ns
public class Geometry
{
public static void main(String args[])
{
long start, end;
int ITER = 5000000;
/* WARMING UP */
// traditional way
start = getTime();
double alpha = Math.acos( (float)3/4);
double beta = Math.PI - Math.PI/4 - alpha;
double d = 5 * Math.sin(alpha) / Math.sin(beta);
end = getTime();
System.out.println(d + " computed in " + (end-start) + "ns");
// rational geometry
start = getTime();
double q1 = 1400 - 525*Math.sqrt(7);
double d1 = Math.sqrt(q1);
end = getTime();
System.out.println(d1 + " computed in " + (end-start) + "ns");
/* WE ARE WARMED UP */
// traditional way
start = getTime();
for(int i=0; i
{
alpha = Math.acos( (float)3/4);
// System.out.println("alpha: " + alpha);
beta = Math.PI - Math.PI/4 - alpha;
// System.out.println("beta: " + beta);
d = 5 * Math.sin(alpha) / Math.sin(beta);
}
end = getTime();
System.out.println(d + " computed in " + (end-start)/(float)ITER + "ns");
// rational geometry
start = getTime();
for(int i=0; i
{
q1 = 1400 - 525*Math.sqrt(7);
d1 = Math.sqrt(q1);
}
end = getTime();
System.out.println(d1 + " computed in " + (end-start)/(float)ITER+ "ns");
}
public final static long getTime()
{
return System.nanoTime();
}
}