Tuesday, October 20, 2009

Little game to make your friends wonder you are a wizard

Ask your math pal to think a math formula, or better a polynomy of quadratic order p(x). Ask her not to disclose it, but to compute p(0), p(1), p(2) ang give to you the results. How can you surprise your pal by guessing the correct p(x)?


  1. p(x) = ax^2 + bx + c

    c = p(0)
    a = (p(2) - p(1) + c)/2
    b = (3p(1) - 3c - p(2))/2

  2. from scipy import linalg, mat
    print " + ".join(["%s%s" % (j, i) for i, j in zip(("x^2","x", ""), linalg.solve(mat([[0,0,1],[1,1,1],[4,2,1]]), mat