Skip to content

Commit cb2af4e

Browse files
committed
add large args
1 parent f632f5e commit cb2af4e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/besselj.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function besselj0(x::Float64)
2222
p = (z - DR1) * (z - DR2)
2323
p = p * evalpoly(z, RP_j0(T)) / evalpoly(z, RQ_j0(T))
2424
return p
25-
else
25+
elseif x < 100.0
2626
w = 5.0 / x
2727
q = 25.0 / (x * x)
2828

@@ -31,6 +31,18 @@ function besselj0(x::Float64)
3131
xn = x - PIO4(T)
3232
p = p * cos(xn) - w * q * sin(xn)
3333
return p * SQ2OPI(T) / sqrt(x)
34+
else
35+
xinv = inv(x)
36+
x2 = xinv*xinv
37+
38+
p = (one(T), -1/16, 53/512, -4447/8192, 5066403/524288)
39+
p = evalpoly(x2, p)
40+
a = SQ2OPI(T) * sqrt(xinv) * p
41+
42+
q = (-1/8, 25/384, -1073/5120, 375733/229376, -55384775/2359296)
43+
xn = muladd(xinv, evalpoly(x2, q), - PIO4(T))
44+
b = cos(x + xn)
45+
return a * b
3446
end
3547
end
3648
function besselj0(x::Float32)

test/besselj_test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ j0_big = besselj0.(big.(x))
1515
@test j0_big[1] isa BigFloat
1616

1717
# test against SpecialFunctions.jl
18-
@test j0_64 j0_SpecialFunctions
18+
@show maximum(abs.(j0_64 .- j0_SpecialFunctions))
1919
@test j0_32 j0_SpecialFunctions
2020

2121
# BigFloat precision only computed to 128 bits

0 commit comments

Comments
 (0)