Evaluating Laplacian using sympy does not match Wolfram-Alpha

49 views Asked by At

I have a function whose Laplacian needs to be solved and evaluated. Using sympy and Wolfram-Alpha I can obtain the Laplacian and evaluate it, the problem is that the values do not match.

import numpy as np
import sympy

# Constants
A = -1.3
B = 5.4
C = 7.9
# Evaluation points for variables `x,y`
x_eval = 2.4
y_eval = 6.5

# Solve and evaluate Laplacian of `func` using sympy
x = sympy.symbols('rho', real=True, positive=True)
y = sympy.symbols('z', real=True, positive=True)
func = A / sympy.sqrt(x**2 + (B + sympy.sqrt(y**2 + C**2))**2)
laplace_f = sympy.laplace_transform(func, x, y, noconds=True)
print("sympy:", laplace_f.evalf(subs={x: x_eval, y: y_eval}))

# Evaluate solved Laplacian of `func` by Wolfram-Alpha
WA_laplace_f = (
    -(A * (B**3 * C + B**2 * (4 * C - y_eval**2) * np.sqrt(C + y_eval**2) + B * (5 * C**2 + C * (x_eval**2 + 3 * y_eval**2) - 2 * y_eval**4) +
    np.sqrt(C + y_eval**2) * (2 * C**2 + C * (y_eval**2 - x_eval**2) - y_eval**2 * (x_eval**2 + y_eval**2)))) /
    ((C + y_eval**2)**(3/2) * (B**2 + 2 * B * np.sqrt(C + y_eval**2) + C + x_eval**2 + y_eval**2)**(5/2)))
print("Wolfram:", WA_laplace_f)

The results are:

sympy:   -0.0127943826586774
Wolfram: -0.0002685293588919364

What am I missing here?

0

There are 0 answers