alpar@1: /*Arithmetic Mean of a large number of Integers alpar@1: - or - solve a very large constraint matrix alpar@1: over 1 million rows and columns alpar@1: Nigel_Galloway@operamail.com alpar@1: March 18th., 2008. alpar@1: */ alpar@1: alpar@1: param e := 20; alpar@1: /* set Sample := {-2**e..2**e-1}; */ alpar@1: set Sample := {1..2**e-1}; alpar@1: alpar@1: var Mean; alpar@1: var E{z in Sample}; alpar@1: alpar@1: /* sum of variances is zero */ alpar@1: zumVariance: sum{z in Sample} E[z] = 0; alpar@1: alpar@1: /* Mean + variance[n] = Sample[n] */ alpar@1: variances{z in Sample}: Mean + E[z] = z; alpar@1: alpar@1: solve; alpar@1: alpar@1: printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean; alpar@1: alpar@1: end;