Skip to content
DeepForgeby svx
All problems
HardCalculusca-162

Laplacian in Polar Coordinates

Problem

In polar coordinates the Laplacian is Laplacian(f) = f_rr + (1/r)*f_r + (1/r^2)*f_theta_theta.

Compute each term with central differences (step h = 1e-5) for the function given by the coefficient grid coeffs[i][j] * r^i * theta^j and evaluate at (r, theta). Ragged rows are allowed.

Hint

The 1/r and 1/r^2 weights distinguish this from the Cartesian Laplacian.

Test cases

case 1
in: [[[0,0],[0,0],[1,0]],2,0.5]
expected: 4.000000165493844
case 2
in: [[[0,1]],2,0.5]
expected: -1.3877787807814454e-7
case 3
in: [[[0,0],[0,0],[0,1]],2,0.5]
expected: 1.99999952763541
case 4
in: [[[],[0,0,1]],2,1]
expected: 1.500001192966671
Starter codePython
def polar_laplacian(coeffs, r, theta, h=1e-5):
    # Your code here
    pass

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