2025년 2월 17일 월요일

vi column edit in WSL (windows subsystem linux)

 Ususal key binding ""ctrl+v"" in vim conflicts with Windows "paste". 

To avoid this, one can change the Windows terminal key binding for copy and paste 

into "ctrl+shift+c" and  "ctrl+shift+v"


Edit %LocalAppData%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json file.

And change

Original :

{
    "command": 
    {
        "action": "copy",
        "singleLine": false
    },
    "keys": "ctrl+c" 
},
{
    "command": "paste",
    "keys": "ctrl+v"
},

Modified :

{
    "command": 
    {
        "action": "copy",
        "singleLine": false
    },
    "keys": "ctrl+shift+c"
},
{
    "command": "paste",
    "keys": "ctrl+shift+v"

},

2025년 2월 11일 화요일

Principal value integration in scipy (dispersion relation)

 To compute a principal value integration

$\frac{E-E_s}{\pi} \int_0^\infty dx \frac{W(x)}{(x-E_s)(x-E)}$

One can change it into 

$\frac{1}{\pi} \int_0^\infty dx \frac{W(x)}{(x-E)} - \frac{W(x)}{(x-E_s)}$

then using weight='cauchy' in quadpack, ( which multiply 1/(x-wvar) ) 

one can compute the integration as 

quad(w,0.,200.,weight='cauchy',wvar=ee)[0]/np.pi -quad(w,0.,200.,weight='cauchy',wvar=es)[0]/np.pi


In case of Wolfram language, one can use 

NIntegrate[(ee-Es)/Pi*W[x]/(x-Es)/(x-ee),{x,0,400.},PrincipalValue->True,PrecisionGoal->10,Method->"GlobalAdaptive",Exclusions->{6.0,ee}]