Skip to content
DeepForgeby svx
All problems
HardCalculusca-139

Poisson Bracket

Problem

Compute the Poisson bracket {f, g} = df/dq * dg/dp - df/dp * dg/dq at (q, p).

f_coeffs and g_coeffs are coefficient grids where coeffs[i][j] multiplies q^i * p^j; ragged rows are allowed. Differentiate each polynomial analytically and combine the four partials.

Hint

The bracket is antisymmetric, and {q, p} = 1 for canonical coordinates.

Test cases

case 1
in: [[[0],[1]],[[0,1]],2,3]
expected: 1
case 2
in: [[[0],[1]],[[0,0,0.5],[0],[0.5]],1,1]
expected: 1
case 3
in: [[[0,1]],[[0,0,0.5],[0],[0.5]],2,1]
expected: -2
case 4
in: [[[0,0],[0,1]],[[0,0,1],[0,0],[1,0]],1,2]
expected: 6
Starter codePython
def poisson_bracket(f_coeffs, g_coeffs, q, p):
    # Your code here
    pass

4 test cases · run your code against them in the editor