-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newton fails with abs #98
Comments
It looks like the fact an interval should not be bisected on its center was lost on recent update julia> roots(f, -1000..1000.001, Newton)
2-element Array{Root{Interval{Float64}},1}:
Root([0.165881, 0.165943], :unique)
Root([-2.16602, -2.16504], :unique) |
Still not fixed despite the corrections in #93. Seems that the problem is indeed the absolute value: julia> f(p) = abs(1 / ( (1+p)^30 ) * 10_000 - 100)
f (generic function with 1 method)
julia> roots(f, -1000..1000, Newton)
2-element Array{Root{Interval{Float64}},1}:
Root(∅, :unique)
Root(∅, :unique)
julia> f3(p) = (1 / ( (1+p)^30 ) * 10_000 - 100)^2
f3 (generic function with 1 method)
julia> roots(f3, -1000..1000, Newton)
2-element Array{Root{Interval{Float64}},1}:
Root([0.16551, 0.166413], :unknown)
Root([-2.16653, -2.16564], :unknown) (squaring instead of taking the absolute value should yield a very similar problem) The julia> fp(x) = derivative(f, x)
fp (generic function with 1 method)
julia> fp((-2.167..(-2.165)))
[2378.6, 2770.9]
julia> fp(-2.167)
-2499.911977412291
julia> fp(-2.165)
2636.4380353856686 |
I think this will require directly specifying how the derivative of |
In Note that the above answer is valid for small enough I hope this may help. |
What I mean is that we should define the derivative of function abs_derivative(x::Interval{T}) where {T}
0 ∈ x && return Interval{T}(-1, 1)
x.hi < 0 && return Interval{T}(-1)
return Interval{T}(1)
end But I don't know how to plug this into |
This should now be fixable after JuliaDiff/DiffRules.jl#33. |
The text was updated successfully, but these errors were encountered: