Skip to content

Commit

Permalink
Merge pull request #57 from andreasnoack/an/fix
Browse files Browse the repository at this point in the history
Use max instead of + when combining abs- and relstep.
  • Loading branch information
ChrisRackauckas committed May 29, 2019
2 parents 7616865 + a07a909 commit 8a9f60d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/finitediff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Compute the finite difference interval epsilon.
Reference: Numerical Recipes, chapter 5.7.
=#
@inline function compute_epsilon(::Type{Val{:forward}}, x::T, relstep::Real, absstep::Real) where T<:Number
return relstep*abs(x) + absstep
return max(relstep*abs(x), absstep)
end

@inline function compute_epsilon(::Type{Val{:central}}, x::T, relstep::Real, absstep::Real) where T<:Number
return relstep*abs(x) + absstep
return max(relstep*abs(x), absstep)
end

@inline function compute_epsilon(::Type{Val{:complex}}, x::T, ::Union{Nothing,T}=nothing, ::Union{Nothing,T}=nothing) where T<:Real
Expand Down

0 comments on commit 8a9f60d

Please sign in to comment.