//
// Averages/Pythagorean means in SETL.
// From
// http://rosettacode.org/wiki/Averages/Pythagorean_means
// (edited)
// """
// Compute all three of the Pythagorean means of the set of integers
// 1 through 10.
// Show that A(x1,..,xn) >= G(x1,..,xn) >= H(x1,..,x_n) for this set
// of positive integers.
//
// * A: The most common of the three means, the arithmetic mean, is the
// sum of the list divided by its length.
//
// * G: The geometric mean is the nth root of the product of the list.
//
// * H: The harmonic mean is n divided by the sum of the reciprocal
// of each item in the list.
// """
//
// This SETL program was created by Hakan Kjellerstrand (hakank@bonetmail.com)
// Also see my SETL page: http://www.hakank.org/setl/
//
mean_A := procedure(x) {
return 1.0*+/x/#x;
};
mean_G := procedure(x) {
return (*/x)**(1.0/#x);
};
mean_H := procedure(x) {
return #x/+/[1.0/i:i in x];
};
x := [1..10];
a := mean_A(x);
g := mean_G(x);
h := mean_H(x);
print("A:$a$ G:$g$ H:$h$");
print(a >= g && g >= h);