[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hard sums, easy formula



PureBytes Links

Trading Reference Links

Hi Hugh,

not being able to receive any mail, I have no idea if an explanation of the
formula in question is still needed; but since I promised to post something,
here goes.

The whole thing is a simple interpolation problem, a quadratic one in our
case. You can easily see what is needed from the attached picture. We have
to find a formula for the interpolating curve first, and then get the
corresponding step function by application of "Floor".

Here is the pattern for the contracts and account sizes:

C	 A
1	10=10
2	15=10 + 1*5
3	25=10 + 1*5 +2*5
.......
i	   10 + (1+2+...+(i-1))*5

Remembering the formula for the sum of the first n integers, n(n+1)/2, we
see that for the points (10,1), (15,2), (25,3),..., generally, for (C,A), we
have a simple equation:

	A = 10 + 5*C*(C-1)/2

Solving this quadratic equation for C, and discarding the spurious solution,
we get

	C = 0.1*(Sqrt(5)*Sqrt(8*A-75)+5)

Now that we have the equation of the interpolating curve, we simply wrap
"Floor" around the expression, to get the staicase function

	C = Floor(0.1*(Sqrt(5)*Sqrt(8*A-75)+5))

and we are done. If only one square root is desired, we can write

	C = Floor(0.1*(Sqrt(40*A-375)+0.5)

which is the very same thing, and may look a little less intimidating. There
are many more ways to write this.

Of course, it is easy to generalize our solution for arbitrary minimum
account sizes (M) and deltas (D). The corresponding equation is now:

	A = M + D*C*(C-1)/2

Solving for C again, and wrapping the solution into "Floor", we get:

	C = Floor(0.5*(Sqrt((8*(A-M)+D)/D)+1)),

which you can use with M=10000 and D=5000 to get the result you mentioned.

Best regards,

Michael Suesserott









Attachment: Description: "pic.gif"