Skip to content

Commit

Permalink
WIP: Check endpoint inclusion for tan
Browse files Browse the repository at this point in the history
  • Loading branch information
dpsanders committed Apr 11, 2018
1 parent 564d060 commit 5f1e3ae
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/intervals/trigonometric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,41 @@ function tan(a::Interval{T}) where T

diam(a) > pi_interval(T).lo && return entireinterval(a)

lo_quadrant = minimum(find_quadrants(a.lo))
hi_quadrant = maximum(find_quadrants(a.hi))
lo_quadrants = find_quadrants(a.lo)

if lo_quadrants[1] == lo_quadrants[2] # unambiguous quadrant
lo_quadrant = lo_quadrants[1]

else # check if end-point is really in the other quadrant
if lo_quadrants[2] * half_pi(T) a
lo_quadrant = lo_quadrants[1]

else
lo_quadrant = lo_quadrants[2]
end

end

hi_quadrants = find_quadrants(a.hi)

if hi_quadrants[1] == hi_quadrants[2]
hi_quadrant = hi_quadrants[1]

else # check if end-point is really in the other quadrant
if hi_quadrants[2] * half_pi(T) a
hi_quadrant = hi_quadrants[2]

else
hi_quadrant = hi_quadrants[1]
end

end

lo_quadrant_mod = mod(lo_quadrant, 2)
hi_quadrant_mod = mod(hi_quadrant, 2)

if lo_quadrant_mod == 0 && hi_quadrant_mod == 1
# check if really contains singularity:
if hi_quadrant * half_pi(T) a
return entireinterval(a) # crosses singularity
end
return entireinterval(a) # crosses singularity

elseif lo_quadrant_mod == hi_quadrant_mod && hi_quadrant > lo_quadrant
# must cross singularity
Expand Down

0 comments on commit 5f1e3ae

Please sign in to comment.