The R Project SVN R

Rev

Rev 74265 | Rev 79309 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 74265 Rev 75809
Line 24... Line 24...
24
  \eqn{I_{\nu}}{I(nu)} and \eqn{K_{\nu}}{K(nu)}.
24
  \eqn{I_{\nu}}{I(nu)} and \eqn{K_{\nu}}{K(nu)}.
25
}
25
}
26
\arguments{
26
\arguments{
27
  \item{x}{numeric, \eqn{\ge 0}.}
27
  \item{x}{numeric, \eqn{\ge 0}.}
28
 
28
 
29
  \item{nu}{numeric; The \emph{order} (maybe fractional!) of the
29
  \item{nu}{numeric; The \emph{order} (maybe fractional and negative) of
30
    corresponding Bessel function.}
30
    the corresponding Bessel function.}
31
 
31
 
32
  \item{expon.scaled}{logical; if \code{TRUE}, the results are
32
  \item{expon.scaled}{logical; if \code{TRUE}, the results are
33
    exponentially scaled in order to avoid overflow
33
    exponentially scaled in order to avoid overflow
34
    (\eqn{I_{\nu}}{I(nu)}) or underflow (\eqn{K_{\nu}}{K(nu)}),
34
    (\eqn{I_{\nu}}{I(nu)}) or underflow (\eqn{K_{\nu}}{K(nu)}),
35
    respectively.}
35
    respectively.}
Line 90... Line 90...
90
 
90
 
91
  Campbell, J.B. (1980).
91
  Campbell, J.B. (1980).
92
  On Temme's algorithm for the modified Bessel function of the third kind.
92
  On Temme's algorithm for the modified Bessel function of the third kind.
93
  \emph{ACM Transactions on Mathematical Software}, \bold{6}(4), 581--586.
93
  \emph{ACM Transactions on Mathematical Software}, \bold{6}(4), 581--586.
94
  \doi{10.1145/355921.355928}.
94
  \doi{10.1145/355921.355928}.
95
  
95
 
96
  Campbell, J.B. (1979).
96
  Campbell, J.B. (1979).
97
  Bessel functions J_nu(x) and Y_nu(x) of float order and float argument.
97
  Bessel functions J_nu(x) and Y_nu(x) of float order and float argument.
98
  \emph{Computer Physics Communications}, \bold{18}, 133--142.
98
  \emph{Computer Physics Communications}, \bold{18}, 133--142.
99
  \doi{10.1016/0010-4655(79)90030-4}.
99
  \doi{10.1016/0010-4655(79)90030-4}.
100
 
100
 
Line 124... Line 124...
124
plot(x, x, ylim = c(0, 6), ylab = "", type = "n",
124
plot(x, x, ylim = c(0, 6), ylab = "", type = "n",
125
     main = "Bessel Functions  I_nu(x)")
125
     main = "Bessel Functions  I_nu(x)")
126
for(nu in nus) lines(x, besselI(x, nu = nu), col = nu + 2)
126
for(nu in nus) lines(x, besselI(x, nu = nu), col = nu + 2)
127
legend(0, 6, legend = paste("nu=", nus), col = nus + 2, lwd = 1)
127
legend(0, 6, legend = paste("nu=", nus), col = nus + 2, lwd = 1)
128
 
128
 
129
x <- seq(0, 40, length.out = 801); yl <- c(-.8, .8)
129
x <- seq(0, 40, length.out = 801); yl <- c(-.5, 1)
130
plot(x, x, ylim = yl, ylab = "", type = "n",
130
plot(x, x, ylim = yl, ylab = "", type = "n",
131
     main = "Bessel Functions  J_nu(x)")
131
     main = "Bessel Functions  J_nu(x)")
-
 
132
abline(h=0, v=0, lty=3)
132
for(nu in nus) lines(x, besselJ(x, nu = nu), col = nu + 2)
133
for(nu in nus) lines(x, besselJ(x, nu = nu), col = nu + 2)
133
legend(32, -.18, legend = paste("nu=", nus), col = nus + 2, lwd = 1)
134
legend("topright", legend = paste("nu=", nus), col = nus + 2, lwd = 1, bty="n")
134
 
135
 
135
## Negative nu's :
136
## Negative nu's --------------------------------------------------
136
xx <- 2:7
137
xx <- 2:7
137
nu <- seq(-10, 9, length.out = 2001)
138
nu <- seq(-10, 9, length.out = 2001)
138
op <- par(lab = c(16, 5, 7))
139
## --- I() --- --- --- ---
139
matplot(nu, t(outer(xx, nu, besselI)), type = "l", ylim = c(-50, 200),
140
matplot(nu, t(outer(xx, nu, besselI)), type = "l", ylim = c(-50, 200),
140
        main = expression(paste("Bessel ", I[nu](x), " for fixed ", x,
141
        main = expression(paste("Bessel ", I[nu](x), " for fixed ", x,
141
                                ",  as ", f(nu))),
142
                                ",  as ", f(nu))),
142
        xlab = expression(nu))
143
        xlab = expression(nu))
143
abline(v = 0, col = "light gray", lty = 3)
144
abline(v = 0, col = "light gray", lty = 3)
144
legend(5, 200, legend = paste("x=", xx), col=seq(xx), lty=seq(xx))
145
legend(5, 200, legend = paste("x=", xx), col=seq(xx), lty=1:5)
145
par(op)
-
 
146
 
146
 
147
x0 <- 2^(-20:10)
147
## --- J() --- --- --- ---
-
 
148
bJ <- t(outer(xx, nu, besselJ))
148
plot(x0, x0^-8, log = "xy", ylab = "", type = "n",
149
matplot(nu, bJ, type = "l", ylim = c(-500, 200),
149
     main = "Bessel Functions  J_nu(x)  near 0\n log - log  scale")
150
        xlab = quote(nu), ylab = quote(J[nu](x)),
150
for(nu in sort(c(nus, nus+0.5)))
151
        main = expression(paste("Bessel ", J[nu](x), " for fixed ", x)))
151
    lines(x0, besselJ(x0, nu = nu), col = nu + 2)
152
abline(v = 0, col = "light gray", lty = 3)
152
legend(3, 1e50, legend = paste("nu=", paste(nus, nus+0.5, sep=",")),
153
legend("topright", legend = paste("x=", xx), col=seq(xx), lty=1:5)
153
       col = nus + 2, lwd = 1)
-
 
154
 
154
 
-
 
155
## ZOOM into right part:
-
 
156
matplot(nu[nu > -2], bJ[nu > -2,], type = "l",
-
 
157
        xlab = quote(nu), ylab = quote(J[nu](x)),
-
 
158
        main = expression(paste("Bessel ", J[nu](x), " for fixed ", x)))
-
 
159
abline(h=0, v = 0, col = "gray60", lty = 3)
-
 
160
legend("topright", legend = paste("x=", xx), col=seq(xx), lty=1:5)
-
 
161
 
-
 
162
 
-
 
163
##---------------  x --> 0  -----------------------------
-
 
164
x0 <- 2^seq(-16, 5, length.out=256)
-
 
165
plot(range(x0), c(1e-40, 1), log = "xy", xlab = "x", ylab = "", type = "n",
-
 
166
     main = "Bessel Functions  J_nu(x)  near 0\n log - log  scale") ; axis(2, at=1)
-
 
167
for(nu in sort(c(nus, nus+0.5)))
-
 
168
    lines(x0, besselJ(x0, nu = nu), col = nu + 2, lty= 1+ (nu\%\%1 > 0))
-
 
169
legend("right", legend = paste("nu=", paste(nus, nus+0.5, sep=", ")),
-
 
170
       col = nus + 2, lwd = 1, bty="n")
-
 
171
 
-
 
172
x0 <- 2^seq(-10, 8, length.out=256)
155
plot(x0, x0^-8, log = "xy", ylab = "", type = "n",
173
plot(range(x0), 10^c(-100, 80), log = "xy", xlab = "x", ylab = "", type = "n",
156
     main = "Bessel Functions  K_nu(x)  near 0\n log - log  scale")
174
     main = "Bessel Functions  K_nu(x)  near 0\n log - log  scale") ; axis(2, at=1)
157
for(nu in sort(c(nus, nus+0.5)))
175
for(nu in sort(c(nus, nus+0.5)))
158
    lines(x0, besselK(x0, nu = nu), col = nu + 2)
176
    lines(x0, besselK(x0, nu = nu), col = nu + 2, lty= 1+ (nu\%\%1 > 0))
159
legend(3, 1e50, legend = paste("nu=", paste(nus, nus + 0.5, sep = ",")),
177
legend("topright", legend = paste("nu=", paste(nus, nus + 0.5, sep = ", ")),
160
       col = nus + 2, lwd = 1)
178
       col = nus + 2, lwd = 1, bty="n")
161
 
179
 
162
x <- x[x > 0]
180
x <- x[x > 0]
163
plot(x, x, ylim = c(1e-18, 1e11), log = "y", ylab = "", type = "n",
181
plot(x, x, ylim = c(1e-18, 1e11), log = "y", ylab = "", type = "n",
164
     main = "Bessel Functions  K_nu(x)")
182
     main = "Bessel Functions  K_nu(x)"); axis(2, at=1)
165
for(nu in nus) lines(x, besselK(x, nu = nu), col = nu + 2)
183
for(nu in nus) lines(x, besselK(x, nu = nu), col = nu + 2)
166
legend(0, 1e-5, legend=paste("nu=", nus), col = nus + 2, lwd = 1)
184
legend(0, 1e-5, legend=paste("nu=", nus), col = nus + 2, lwd = 1)
167
 
185
 
168
yl <- c(-1.6, .6)
186
yl <- c(-1.6, .6)
169
plot(x, x, ylim = yl, ylab = "", type = "n",
187
plot(x, x, ylim = yl, ylab = "", type = "n",