How to avoid inf/inf numerically for hyperbolic functions
I have an expression which consist of hyperbolic functions so to avoid the numerically instability how i can write them in exponential form in coding. I have those expressions in fortan code. Now i want to use them in MATLAB for my problem but i did not get that required form. The parameters i have are h=200, d= 38 , gamma is the positive roots for bessel functions.
and
Now the fortan code they write for C_n is:
kmR(iM)=BesJzero(iM) ! this is the gamma they just used the scaled one but analytically this gamma.
kmH(iM)=kmR(iM)*HsR ! this is gamm*h
exp1kmD(iM)=exp(-kmH(iM)*dsD/wtH) ! this is exp(-gamma*d)
exp2kmD(iM)=exp(-(kmH(iM)+kmH(iM))*dsD/wtH) ! this is exp(-2 gamma *d)
exp2kmH(iM)=exp(-(kmH(iM)+kmH(iM))) ! this is exp(-2 gamma *h)
exp2kmHmD(iM)=exp(-(kmH(iM)+kmH(iM))*HmD) ! this is exp(-2 gamma(h-d))
BBm(iM)=(nuR-kmR(iM))*exp2kmHmD(iM)/exp2kmD(iM) ! this nuR is f^2 and
BBm(iM)=BBm(iM)+(nuR+kmR(iM))*(1.0D0+2.0D0*exp2kmHmD(iM))
BBm(iM)=BBm(iM)/(nuR-kmR(iM)+(nuR+kmR(iM))*exp2kmD(iM))
BBm(iM)=BBm(iM)/(1.0D0+exp2kmHmD(iM))
CCm(iM)=2.0D0*(BBm(iM)*exp2kmD(iM)-1.0D0)
And for phi_U is
CCmc(iM)=1.0D0+exp2kmHmD(iM)/exp2kmD(iM)+2.0D0*exp2kmHmD(iM)
CCmc(iM)=CCmc(iM)/(1.0D0+exp2kmHmD(iM))
CCmc(iM)=BBm(iM)*(1.0D0+exp2kmD(iM))-CCmc(iM)
CCmc(iM)=CCmc(iM)*exp1kmD(iM)I have an expression which consist of hyperbolic functions so to avoid the numerically instability how i can write them in exponential form in coding. I have those expressions in fortan code. Now i want to use them in MATLAB for my problem but i did not get that required form. The parameters i have are h=200, d= 38 , gamma is the positive roots for bessel functions.
and
Now the fortan code they write for C_n is:
kmR(iM)=BesJzero(iM) ! this is the gamma they just used the scaled one but analytically this gamma.
kmH(iM)=kmR(iM)*HsR ! this is gamm*h
exp1kmD(iM)=exp(-kmH(iM)*dsD/wtH) ! this is exp(-gamma*d)
exp2kmD(iM)=exp(-(kmH(iM)+kmH(iM))*dsD/wtH) ! this is exp(-2 gamma *d)
exp2kmH(iM)=exp(-(kmH(iM)+kmH(iM))) ! this is exp(-2 gamma *h)
exp2kmHmD(iM)=exp(-(kmH(iM)+kmH(iM))*HmD) ! this is exp(-2 gamma(h-d))
BBm(iM)=(nuR-kmR(iM))*exp2kmHmD(iM)/exp2kmD(iM) ! this nuR is f^2 and
BBm(iM)=BBm(iM)+(nuR+kmR(iM))*(1.0D0+2.0D0*exp2kmHmD(iM))
BBm(iM)=BBm(iM)/(nuR-kmR(iM)+(nuR+kmR(iM))*exp2kmD(iM))
BBm(iM)=BBm(iM)/(1.0D0+exp2kmHmD(iM))
CCm(iM)=2.0D0*(BBm(iM)*exp2kmD(iM)-1.0D0)
And for phi_U is
CCmc(iM)=1.0D0+exp2kmHmD(iM)/exp2kmD(iM)+2.0D0*exp2kmHmD(iM)
CCmc(iM)=CCmc(iM)/(1.0D0+exp2kmHmD(iM))
CCmc(iM)=BBm(iM)*(1.0D0+exp2kmD(iM))-CCmc(iM)
CCmc(iM)=CCmc(iM)*exp1kmD(iM) I have an expression which consist of hyperbolic functions so to avoid the numerically instability how i can write them in exponential form in coding. I have those expressions in fortan code. Now i want to use them in MATLAB for my problem but i did not get that required form. The parameters i have are h=200, d= 38 , gamma is the positive roots for bessel functions.
and
Now the fortan code they write for C_n is:
kmR(iM)=BesJzero(iM) ! this is the gamma they just used the scaled one but analytically this gamma.
kmH(iM)=kmR(iM)*HsR ! this is gamm*h
exp1kmD(iM)=exp(-kmH(iM)*dsD/wtH) ! this is exp(-gamma*d)
exp2kmD(iM)=exp(-(kmH(iM)+kmH(iM))*dsD/wtH) ! this is exp(-2 gamma *d)
exp2kmH(iM)=exp(-(kmH(iM)+kmH(iM))) ! this is exp(-2 gamma *h)
exp2kmHmD(iM)=exp(-(kmH(iM)+kmH(iM))*HmD) ! this is exp(-2 gamma(h-d))
BBm(iM)=(nuR-kmR(iM))*exp2kmHmD(iM)/exp2kmD(iM) ! this nuR is f^2 and
BBm(iM)=BBm(iM)+(nuR+kmR(iM))*(1.0D0+2.0D0*exp2kmHmD(iM))
BBm(iM)=BBm(iM)/(nuR-kmR(iM)+(nuR+kmR(iM))*exp2kmD(iM))
BBm(iM)=BBm(iM)/(1.0D0+exp2kmHmD(iM))
CCm(iM)=2.0D0*(BBm(iM)*exp2kmD(iM)-1.0D0)
And for phi_U is
CCmc(iM)=1.0D0+exp2kmHmD(iM)/exp2kmD(iM)+2.0D0*exp2kmHmD(iM)
CCmc(iM)=CCmc(iM)/(1.0D0+exp2kmHmD(iM))
CCmc(iM)=BBm(iM)*(1.0D0+exp2kmD(iM))-CCmc(iM)
CCmc(iM)=CCmc(iM)*exp1kmD(iM) hyperbolic functions, numerical instability, exponential form MATLAB Answers — New Questions