Ask Your Question

samosonto's profile - activity

2023-07-20 20:10:50 +0200 received badge  Popular Question (source)
2022-03-05 18:28:15 +0200 commented answer Error from integration using mpmath quad

This is exactly what I aimed at. Thank you very much!

2022-03-05 18:28:00 +0200 marked best answer Error from integration using mpmath quad

Hello all,

I am trying to solve an integral with one variable kx and then I need the result from that integral to be evaluated in a point defined by x,y coordinates.

The code I am using is the following:

import numpy as np
from numpy.lib.scimath import sqrt
from mpmath import *
import matplotlib.pyplot as plt
mp.dps = 15

f = 8500
rho = 1.225 
c0 = 343 
Omega = 2*np.pi*f  
k = Omega/c0 
Z = -426   

integrandReal = lambda kx, x, y: np.real(((2*sqrt(k**2 - kx**2)*Z)/(sqrt(k**2 - kx**2)*Z + Omega*rho))*((np.exp(1j*(kx*x + sqrt(k**2 - kx**2)*y)))/(sqrt(k**2 - kx**2))))
integrandImag = lambda kx, x, y: np.imag(((2*sqrt(k**2 - kx**2)*Z)/(sqrt(k**2 - kx**2)*Z + Omega*rho))*((np.exp(1j*(kx*x + sqrt(k**2 - kx**2)*y)))/(sqrt(k**2 - kx**2))))

integral = lambda x, y: quad(integrandReal, [-100*k, 100*k], [x], [y])  + 1j*quad(integrandImag, [-100*k, 100*k], [x], [y])
G = integral(0,0)

My problem is that for any value of x and ythat I use I get:

mpc(real='0.0', imag='0.0')

I appreciate any help to solve this!

2022-03-05 18:28:00 +0200 received badge  Scholar (source)
2022-03-05 18:27:34 +0200 answered a question Error from integration using mpmath quad

This is exactly what I aimed at. Thank you very much!

2022-03-05 18:26:54 +0200 commented question Error from integration using mpmath quad

My mistake! I was just playing before with other expressions and I left numpy in the code.

2022-03-03 22:33:39 +0200 commented question Error from integration using mpmath quad

It makes sense what you say. I was trying to apply something similar to how scipy works. The problem of scipy is that th

2022-03-03 18:02:42 +0200 received badge  Student (source)
2022-03-03 18:02:02 +0200 asked a question Error from integration using mpmath quad

Error from integration using mpmath quad Hello all, I am trying to solve an integral with one variable kx and then I ne