 ## Author: TURHAN <TURHAN@DESKTOP-E5V4CKD>
## Created: 2021-05-27
function JJ = bessel_J(v,x)
    JJ=0;
    a=1.0;
    fact=1;
    b=0.0;
    if x <=20
        x5=1;
        lna=0.0;
        x1=v*log(0.5*x);
        lna1=log(0.25*x*x);
        for k=0:100
            x2=lna;
            x3=log(gamma(k+1));
            x4=log(gamma(v+k+1));
            b=x1+x2-x3-x4;	       
            b=x5*exp(b);
            lna=lna+lna1;
            x5=-1*x5;
            JJ=JJ+b;
        endfor            
    elseif v==0 && x==0 
        JJ=1;
    else
        JJ=sqrt(2.0/pi/x)*cos(x-0.5*v*pi-0.25*pi);
    endif
endfunction
