### (no subject)

Oh huh you can also really easily make a contract whose value is the geometric mean of two assets. Interestingly, I

"I, the undersigned, promise to deliver, at any time my counterparty requests, a quantity X of shares of XCision and a quantity Y of shares of YonedaCo such that X * Y = 1000"

Suppose Alice gives Bob that contract, and Bob calls Alice on it and asks for his shares. What does Alice do? Making the simplifying assumption of infinite market depth, that XCision and YonedaCorp just

X p_X + (1000 / X) p_Y

is minimized. So we set the derivative to zero,

0 = p_X - (1000 / X^2)p_Y

and discover

X = sqrt(1000(p_Y / p_X))

and so the total amount of value Alice gives to Bob is

sqrt(1000(p_Y / p_X)) p_X + (1000 / sqrt(1000(p_Y / p_X))) p_Y

= 2 sqrt(1000 p_X p_Y)

which is proportional to the geometric mean of the prices of the two original assets, as required.

---

and the "median of a basket of goods" game from yesterday admits a stupidly simple direct description.

Alice and Bob take turns choosing elements of the basket of goods to eliminate, and the last one left, Alice must give one of those to Bob. It's always in Alice's best interest to choose the most expensive remaining item, and it's always in Bob's best interest to choose the cheapest; what remains is the median.

**don't**know how to encode this into the Peyton-Jones/Eber/Seward framework. Here's how it goes:"I, the undersigned, promise to deliver, at any time my counterparty requests, a quantity X of shares of XCision and a quantity Y of shares of YonedaCo such that X * Y = 1000"

Suppose Alice gives Bob that contract, and Bob calls Alice on it and asks for his shares. What does Alice do? Making the simplifying assumption of infinite market depth, that XCision and YonedaCorp just

*have*share prices p_X and p_Y that aren't affected by Alice buying stock, Alice wants to choose an X such thatX p_X + (1000 / X) p_Y

is minimized. So we set the derivative to zero,

0 = p_X - (1000 / X^2)p_Y

and discover

X = sqrt(1000(p_Y / p_X))

and so the total amount of value Alice gives to Bob is

sqrt(1000(p_Y / p_X)) p_X + (1000 / sqrt(1000(p_Y / p_X))) p_Y

= 2 sqrt(1000 p_X p_Y)

which is proportional to the geometric mean of the prices of the two original assets, as required.

---

and the "median of a basket of goods" game from yesterday admits a stupidly simple direct description.

Alice and Bob take turns choosing elements of the basket of goods to eliminate, and the last one left, Alice must give one of those to Bob. It's always in Alice's best interest to choose the most expensive remaining item, and it's always in Bob's best interest to choose the cheapest; what remains is the median.