# Evaluating a function using kramers-kronig relation

21 views (last 30 days)
firas baransi on 2 May 2023
Edited: Dyuman Joshi on 4 May 2023
Hello , I have this function : and want to evalute the function nR using this integral (cauchy principal value) The problem is this integral have 2 variables (one remains constant during the integration) , I spend a lot of time figuring it out and couldn't (I'm relatively new to matlab) , I would be happy if someone provides a code on how to evaluate nR as function for w

Dyuman Joshi on 2 May 2023
Edited: Dyuman Joshi on 4 May 2023
You can use symbolic integration (Note - Requires Symbolic Toolbox)
As you have not provided the value of P, I've defined it as a symbolic variable. You can either use the value of P directly by simply defining it, or use subs to substitute the value in the final expression.
syms w x
val = 2*sym(pi)*10^11;
Tau = 0.25*val;
w0 = 500*val;
K(w) = Tau^2/(2*sym(pi)*((w-w0)^2+Tau^2));
nr(w) = 1 + 2*int(x*K(x)/(x^2-w^2), x, 0, Inf, 'PrincipalValue', 1)/pi
nr(w) = ##### 2 CommentsShow 1 older commentHide 1 older comment
Dyuman Joshi on 3 May 2023
Edited: Dyuman Joshi on 4 May 2023
Ah, I see, thanks for the info, I was not familiar with this syntax. I have edited my answer.

Torsten on 2 May 2023
syms omega omega0 Omega Gamma real
kappa(omega) = 1/(2*pi) * Gamma^2/((omega-omega0)^2 + Gamma^2) ;
nR(omega) = 1 + 2/pi*int(Omega*kappa(Omega)/(Omega^2-omega^2),Omega,0,Inf,'PrincipalValue',1);
vpa(subs(nR(1.2),[Gamma omega0],[0.25*1e11*2*pi,500*1e11*2*pi]))
ans = 