In [1]:
include("newton2d.jl")
Out[1]:
newton2d (generic function with 2 methods)
In [2]:
f(x) = [x[1]^2 + x[2]^2 - 1, x[1] - x[2]^2]
Out[2]:
f (generic function with 1 method)
In [3]:
a = [Interval(0.5, 0.8), Interval(0.6, 0.9)]
Out[3]:
2-element Array{Interval,1}:
Interval(5e-01 with 256 bits of precision,8.000000000000000000000000000000000000000000000000000000000000000000000000000017e-01 with 256 bits of precision)
Interval(5.999999999999999999999999999999999999999999999999999999999999999999999999999948e-01 with 256 bits of precision,9.000000000000000000000000000000000000000000000000000000000000000000000000000052e-01 with 256 bits of precision)
In [5]:
roots = newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(5.69951923076923076632e-01 with 64 bits of precision,6.43645833333333333595e-01 with 64 bits of precision),Interval(7.76909722222222222138e-01 with 64 bits of precision,8.02564102564102564328e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(5.69951923076923076632e-01 with 64 bits of precision,6.43645833333333333595e-01 with 64 bits of precision),Interval(7.76909722222222222138e-01 with 64 bits of precision,8.02564102564102564328e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(6.16649962609692997909e-01 with 64 bits of precision,6.19676057175074426167e-01 with 64 bits of precision),Interval(7.85711856788002042517e-01 with 64 bits of precision,7.86710356930029978083e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(6.16649962609692997909e-01 with 64 bits of precision,6.19676057175074426167e-01 with 64 bits of precision),Interval(7.85711856788002042517e-01 with 64 bits of precision,7.86710356930029978083e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(6.18033201420526032209e-01 with 64 bits of precision,6.18034789347726672202e-01 with 64 bits of precision),Interval(7.86151061673094964761e-01 with 64 bits of precision,7.86151706419289133176e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(6.18033201420526032209e-01 with 64 bits of precision,6.18034789347726672202e-01 with 64 bits of precision),Interval(7.86151061673094964761e-01 with 64 bits of precision,7.86151706419289133176e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(6.18033988749863042703e-01 with 64 bits of precision,6.18033988749926693068e-01 with 64 bits of precision),Interval(7.86151377757410522269e-01 with 64 bits of precision,7.86151377757436125161e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(6.18033988749863042703e-01 with 64 bits of precision,6.18033988749926693068e-01 with 64 bits of precision),Interval(7.86151377757410522269e-01 with 64 bits of precision,7.86151377757436125161e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(6.18033988749894848045e-01 with 64 bits of precision,6.18033988749894848424e-01 with 64 bits of precision),Interval(7.86151377757423285931e-01 with 64 bits of precision,7.8615137775742328631e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(6.18033988749894848045e-01 with 64 bits of precision,6.18033988749894848424e-01 with 64 bits of precision),Interval(7.86151377757423285931e-01 with 64 bits of precision,7.8615137775742328631e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(6.18033988749894848045e-01 with 64 bits of precision,6.18033988749894848424e-01 with 64 bits of precision),Interval(7.86151377757423285931e-01 with 64 bits of precision,7.8615137775742328631e-01 with 64 bits of precision)]]
Function calls: 5
Out[5]:
1-element Array{Array{Interval,1},1}:
[Interval(6.18033988749894848045e-01 with 64 bits of precision,6.18033988749894848424e-01 with 64 bits of precision),Interval(7.86151377757423285931e-01 with 64 bits of precision,7.8615137775742328631e-01 with 64 bits of precision)]
In [7]:
f(roots[1])
Out[7]:
2-element Array{Interval,1}:
Interval(-5.42101086242752217051e-19 with 64 bits of precision,8.673617379884035473e-19 with 64 bits of precision)
Interval(-5.96311194867027438704e-19 with 64 bits of precision,4.87890977618476995303e-19 with 64 bits of precision)
In [5]:
# Works.
In [6]:
# 2nd example from Moore book
In [8]:
f(x) = [20 - 20x[1] - x[2], x[1] - x[2]/20 - 1e-9*exp(x[2]/0.052)]
Out[8]:
f (generic function with 1 method)
In [9]:
a = [Interval(0.5, 1.2), Interval(0.6, 1.2)]
Out[9]:
2-element Array{Interval,1}:
Interval(5e-01 with 64 bits of precision,1.20000000000000000004e+00 with 64 bits of precision)
Interval(5.99999999999999999967e-01 with 64 bits of precision,1.20000000000000000004e+00 with 64 bits of precision)
In [11]:
roots = newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(5.24913596541994085176e-01 with 64 bits of precision,9.54783404920287672335e-01 with 64 bits of precision),Interval(9.04331901594246556598e-01 with 64 bits of precision,1.20000000000000000004e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(5.24913596541994085176e-01 with 64 bits of precision,9.54783404920287672335e-01 with 64 bits of precision),Interval(9.04331901594246556598e-01 with 64 bits of precision,1.20000000000000000004e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.29487402579674734042e-01 with 64 bits of precision,9.47322133828186144428e-01 with 64 bits of precision),Interval(1.05355732343627711643e+00 with 64 bits of precision,1.20000000000000000004e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.29487402579674734042e-01 with 64 bits of precision,9.47322133828186144428e-01 with 64 bits of precision),Interval(1.05355732343627711643e+00 with 64 bits of precision,1.20000000000000000004e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.4405739404211960064e-01 with 64 bits of precision,9.47322133828186144428e-01 with 64 bits of precision),Interval(1.05355732343627711643e+00 with 64 bits of precision,1.11885211915760798037e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.4405739404211960064e-01 with 64 bits of precision,9.47322133828186144428e-01 with 64 bits of precision),Interval(1.05355732343627711643e+00 with 64 bits of precision,1.11885211915760798037e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46028161295262554455e-01 with 64 bits of precision,9.46870644360673580542e-01 with 64 bits of precision),Interval(1.06258711278652839491e+00 with 64 bits of precision,1.07943677409474890645e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.46028161295262554455e-01 with 64 bits of precision,9.46870644360673580542e-01 with 64 bits of precision),Interval(1.06258711278652839491e+00 with 64 bits of precision,1.07943677409474890645e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46407827444742915182e-01 with 64 bits of precision,9.46419276900890626275e-01 with 64 bits of precision),Interval(1.07161446198218747721e+00 with 64 bits of precision,1.07184345110514169289e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.46407827444742915182e-01 with 64 bits of precision,9.46419276900890626275e-01 with 64 bits of precision),Interval(1.07161446198218747721e+00 with 64 bits of precision,1.07184345110514169289e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46414245222457044325e-01 with 64 bits of precision,9.46414248263380555859e-01 with 64 bits of precision),Interval(1.07171503473238888629e+00 with 64 bits of precision,1.07171509555085910917e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.46414245222457044325e-01 with 64 bits of precision,9.46414248263380555859e-01 with 64 bits of precision),Interval(1.07171503473238888629e+00 with 64 bits of precision,1.07171509555085910917e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46414246833517562878e-01 with 64 bits of precision,9.46414246833517668533e-01 with 64 bits of precision),Interval(1.07171506332964663205e+00 with 64 bits of precision,1.07171506332964873995e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.46414246833517562878e-01 with 64 bits of precision,9.46414246833517668533e-01 with 64 bits of precision),Interval(1.07171506332964663205e+00 with 64 bits of precision,1.07171506332964873995e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46414246833517617088e-01 with 64 bits of precision,9.46414246833517617467e-01 with 64 bits of precision),Interval(1.07171506332964765413e+00 with 64 bits of precision,1.07171506332964765488e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.46414246833517617088e-01 with 64 bits of precision,9.46414246833517617467e-01 with 64 bits of precision),Interval(1.07171506332964765413e+00 with 64 bits of precision,1.07171506332964765488e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46414246833517617142e-01 with 64 bits of precision,9.46414246833517617467e-01 with 64 bits of precision),Interval(1.07171506332964765413e+00 with 64 bits of precision,1.07171506332964765488e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.46414246833517617142e-01 with 64 bits of precision,9.46414246833517617467e-01 with 64 bits of precision),Interval(1.07171506332964765413e+00 with 64 bits of precision,1.07171506332964765488e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.46414246833517617142e-01 with 64 bits of precision,9.46414246833517617467e-01 with 64 bits of precision),Interval(1.07171506332964765413e+00 with 64 bits of precision,1.07171506332964765488e+00 with 64 bits of precision)]]
Function calls: 9
Out[11]:
1-element Array{Array{Interval,1},1}:
[Interval(9.46414246833517617142e-01 with 64 bits of precision,9.46414246833517617467e-01 with 64 bits of precision),Interval(1.07171506332964765413e+00 with 64 bits of precision,1.07171506332964765488e+00 with 64 bits of precision)]
In [12]:
f(ans[1])
Out[12]:
2-element Array{Interval,1}:
Interval(-6.39679281766447616064e-18 with 64 bits of precision,4.87890977618476995303e-18 with 64 bits of precision)
Interval(-8.83624770575686113716e-18 with 64 bits of precision,1.20888542232133744399e-17 with 64 bits of precision)
In [10]:
# Works. Krawczyk2d is not yet capable of doing this on such an interval (only on a tiny one)
In [11]:
# 3rd example from Moore
In [61]:
f(x) = [0.5*(-(17.76x[1] - 103.79x[1]^2 + 229.62x[1]^3 - 226.31x[1]^4 + 83.72x[1]^5) + x[2]), 0.2*(-x[1] - 1.5x[2] + 1.2)]
Out[61]:
f (generic function with 1 method)
There are three real roots: {x1 -> 0.062636, x2 -> 0.758243}, {x1 -> 0.88443, x2 -> 0.21038}, {x1 -> 0.285369, x2 -> 0.609754}
In [62]:
a = [Interval(0.01, 5), Interval(0.1, 5)]
Out[62]:
2-element Array{Interval,1}:
Interval(9.9999999999999999998e-03 with 64 bits of precision,5e+00 with 64 bits of precision)
Interval(9.99999999999999999946e-02 with 64 bits of precision,5e+00 with 64 bits of precision)
In [63]:
newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.52558389946483697317e+00 with 64 bits of precision),Interval(9.99999999999999999946e-02 with 64 bits of precision,5e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.52558389946483697317e+00 with 64 bits of precision),Interval(9.99999999999999999946e-02 with 64 bits of precision,5e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,1.2686662376273644769e+00 with 64 bits of precision),Interval(9.99999999999999999946e-02 with 64 bits of precision,5e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,1.2686662376273644769e+00 with 64 bits of precision),Interval(9.99999999999999999946e-02 with 64 bits of precision,5e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,6.41495905915175664469e-01 with 64 bits of precision),Interval(3.72336062723216222939e-01 with 64 bits of precision,4.84710334659612871984e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,6.41495905915175664469e-01 with 64 bits of precision),Interval(3.72336062723216222939e-01 with 64 bits of precision,4.84710334659612871984e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,3.37257266081398510295e-01 with 64 bits of precision),Interval(5.75161822612400992316e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,3.37257266081398510295e-01 with 64 bits of precision),Interval(5.75161822612400992316e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.13368376853307920932e-01 with 64 bits of precision),Interval(6.57754415431128052253e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.13368376853307920932e-01 with 64 bits of precision),Interval(6.57754415431128052253e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.0409028710522643644e-01 with 64 bits of precision),Interval(6.63939808596515708319e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.0409028710522643644e-01 with 64 bits of precision),Interval(6.63939808596515708319e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.0409028710522643644e-01 with 64 bits of precision),Interval(6.63939808596515708319e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]]
Function calls: 6
Out[63]:
1-element Array{Array{Interval,1},1}:
[Interval(9.9999999999999999998e-03 with 64 bits of precision,2.0409028710522643644e-01 with 64 bits of precision),Interval(6.63939808596515708319e-01 with 64 bits of precision,4.73470830452635709981e+00 with 64 bits of precision)]
In [15]:
# Works. Another interval:
In [20]:
a = [Interval(0.7, 0.9), Interval(0.1, 0.3)]
Out[20]:
2-element Array{Interval,1}:
Interval(6.99999999999999999989e-01 with 64 bits of precision,9.00000000000000000033e-01 with 64 bits of precision)
Interval(9.99999999999999999946e-02 with 64 bits of precision,3.00000000000000000011e-01 with 64 bits of precision)
In [21]:
newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(7.99533569108615181306e-01 with 64 bits of precision,9.00000000000000000087e-01 with 64 bits of precision),Interval(1.32402716810851698009e-01 with 64 bits of precision,2.66977620594256545897e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(7.99533569108615181306e-01 with 64 bits of precision,9.00000000000000000087e-01 with 64 bits of precision),Interval(1.32402716810851698009e-01 with 64 bits of precision,2.66977620594256545897e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.49310448278202196964e-01 with 64 bits of precision,9.00000000000000000141e-01 with 64 bits of precision),Interval(1.64941883459212836004e-01 with 64 bits of precision,2.33793034481198535481e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(8.49310448278202196964e-01 with 64 bits of precision,9.00000000000000000141e-01 with 64 bits of precision),Interval(1.64941883459212836004e-01 with 64 bits of precision,2.33793034481198535481e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.74368868193437198753e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.80847351067254425328e-01 with 64 bits of precision,2.17087421204375200919e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(8.74368868193437198753e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.80847351067254425328e-01 with 64 bits of precision,2.17087421204375200919e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.86713661126687165365e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.88028751271188605487e-01 with 64 bits of precision,2.08857559248875223218e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(8.86713661126687165365e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.88028751271188605487e-01 with 64 bits of precision,2.08857559248875223218e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.92042290862508345105e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.05305139424994436743e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(8.92042290862508345105e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.05305139424994436743e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.93576641696621274086e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.04282238868919150697e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(8.93576641696621274086e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.04282238868919150697e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.93683850490391404895e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.04210766339739063622e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(8.93683850490391404895e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.04210766339739063622e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(8.93683850490391404895e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.04210766339739063622e-01 with 64 bits of precision)]]
Function calls: 7
Out[21]:
1-element Array{Array{Interval,1},1}:
[Interval(8.93683850490391404895e-01 with 64 bits of precision,9.00000000000000000195e-01 with 64 bits of precision),Interval(1.89953354713197845736e-01 with 64 bits of precision,2.04210766339739063622e-01 with 64 bits of precision)]
In [18]:
# For some reason, the intervals are still relatively large
In [13]:
a = [Interval(0.11, 0.3), Interval(0.5, 0.69)]
Out[13]:
2-element Array{Interval,1}:
Interval(1.09999999999999999999e-01 with 64 bits of precision,3.00000000000000000011e-01 with 64 bits of precision)
Interval(5e-01 with 64 bits of precision,6.90000000000000000052e-01 with 64 bits of precision)
In [14]:
newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(1.98959862448933060819e-01 with 64 bits of precision,3.00000000000000000038e-01 with 64 bits of precision),Interval(5.22511857040455090476e-01 with 64 bits of precision,6.67360091700711293024e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(1.98959862448933060819e-01 with 64 bits of precision,3.00000000000000000038e-01 with 64 bits of precision),Interval(5.22511857040455090476e-01 with 64 bits of precision,6.67360091700711293024e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.44405284093183400559e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.47605281726672503634e-01 with 64 bits of precision,6.37063143937877733179e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.44405284093183400559e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.47605281726672503634e-01 with 64 bits of precision,6.37063143937877733179e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.67881780072239415627e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.21412146618507056422e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.67881780072239415627e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.21412146618507056422e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.8018905070704416428e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.13207299528637223896e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.8018905070704416428e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.13207299528637223896e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.86802017717913006298e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.08798654854724662804e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.86802017717913006298e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.08798654854724662804e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.90699552997113188816e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.06200298001924541035e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.90699552997113188816e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.06200298001924541035e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.9119045375552936604e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05873030829647089444e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.9119045375552936604e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05873030829647089444e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199878305938713083e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866747796040858154e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.91199878305938713083e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866747796040858154e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199911011646166213e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725992235889437e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.91199911011646166213e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725992235889437e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199911115097032901e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923268644924e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.91199911115097032901e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923268644924e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199911115424146346e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923050569258e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.91199911115424146346e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923050569258e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199911115425180485e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923049879868e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.91199911115425180485e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923049879868e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199911115425183792e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923049877591e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(2.91199911115425183792e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923049877591e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(2.91199911115425183792e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923049877591e-01 with 64 bits of precision)]]
Function calls: 13
Out[14]:
1-element Array{Array{Interval,1},1}:
[Interval(2.91199911115425183792e-01 with 64 bits of precision,3.00000000000000000065e-01 with 64 bits of precision),Interval(5.55929366475467126932e-01 with 64 bits of precision,6.05866725923049877591e-01 with 64 bits of precision)]
In [70]:
a = [Interval(0.01, 1), Interval(0.01, 1)]
Out[70]:
2-element Array{Interval,1}:
Interval(9.9999999999999999998e-03 with 64 bits of precision,1e+00 with 64 bits of precision)
Interval(9.9999999999999999998e-03 with 64 bits of precision,1e+00 with 64 bits of precision)
In [71]:
newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(3.77986706010765157344e-01 with 64 bits of precision,5.05395803514839542323e-01 with 64 bits of precision),Interval(4.63069464323440305111e-01 with 64 bits of precision,5.48008862659489895115e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(3.77986706010765157344e-01 with 64 bits of precision,5.05395803514839542323e-01 with 64 bits of precision),Interval(4.63069464323440305111e-01 with 64 bits of precision,5.48008862659489895115e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(4.38274314608033558981e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(4.38274314608033558981e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
Function calls: 3
Out[71]:
1-element Array{Array{Interval,1},1}:
[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]
In [17]:
# This one looks like a false positive. Why?
In [72]:
sol = newton2d(f, a, 64)
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(3.77986706010765157344e-01 with 64 bits of precision,5.05395803514839542323e-01 with 64 bits of precision),Interval(4.63069464323440305111e-01 with 64 bits of precision,5.48008862659489895115e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(3.77986706010765157344e-01 with 64 bits of precision,5.05395803514839542323e-01 with 64 bits of precision),Interval(4.63069464323440305111e-01 with 64 bits of precision,5.48008862659489895115e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(4.38274314608033558981e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(4.38274314608033558981e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array = roots_array_new => [[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
roots_array_new = push!(roots_array_new,isectext(roots_array[i],N(roots_array[i]))) => [[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]]
Function calls: 3
Out[72]:
1-element Array{Array{Interval,1},1}:
[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]
In [73]:
center(x) = make_intervals(mid(x))
N(f, x) = center(x) - inv(jacobian(f, x))*f(center(x))
Out[73]:
N (generic function with 1 method)
In [74]:
NNN = N(f, sol[1])
Out[74]:
2-element Array{Interval,1}:
Interval(3.87637464474657538128e-01 with 64 bits of precision,5.20025515047235507198e-01 with 64 bits of precision)
Interval(4.5331632330184299542e-01 with 64 bits of precision,5.41575023683561641169e-01 with 64 bits of precision)
In [34]:
inside(sol[1][1], NNN[1])
Out[34]:
true
In [35]:
inside(sol[1][2], NNN[2])
Out[35]:
true
In [38]:
J = jacobian(f, sol[1])
Out[38]:
2x2 Array{Interval,2}:
Interval(-1.76984841281877910762e+00 with 64 bits of precision,3.37773217687788244361e+00 with 64 bits of precision) … Interval(5e-01 with 64 bits of precision,5e-01 with 64 bits of precision)
Interval(-2.00000000000000000016e-01 with 64 bits of precision,-1.99999999999999999976e-01 with 64 bits of precision) Interval(-3.00000000000000000065e-01 with 64 bits of precision,-2.99999999999999999984e-01 with 64 bits of precision)
In [39]:
inv(J)
Out[39]:
2x2 Array{Interval,2}:
Interval(-4.75470083281939574619e-01 with 64 bits of precision,3.2847207327004322624e-01 with 64 bits of precision) … Interval(-1.30300529972210691028e+01 with 64 bits of precision,5.4745345545007204264e-01 with 64 bits of precision)
Interval(-2.18981382180028817362e-01 with 64 bits of precision,3.16980055521293049565e-01 with 64 bits of precision) Interval(-3.69830230363338136068e+00 with 64 bits of precision,5.35336866481404606349e+00 with 64 bits of precision)
In [75]:
left(x::Interval) = Interval(x.lo, mid(x))
right(x::Interval) = Interval(mid(x), x.hi)
function bisect(xx::Vector{Interval})
if length(xx) != 2
error("Only works for 2 at the moment")
end
x, y = xx
@show x
intervals = Vector{Interval}[]
push!(intervals, [left(x), left(y)])
push!(intervals, [left(x), right(y)])
push!(intervals, [right(x), left(y)])
push!(intervals, [right(x), right(y)])
intervals
end
Out[75]:
bisect (generic function with 1 method)
In [76]:
x = sol[1]
Out[76]:
2-element Array{Interval,1}:
Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision)
Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)
In [78]:
y = bisect(x)
x => Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision)
Out[78]:
4-element Array{Array{Interval,1},1}:
[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.41728143876593134902e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.05514570748937910167e-01 with 64 bits of precision)]
[Interval(4.38274314608033558954e-01 with 64 bits of precision,4.41728143876593134902e-01 with 64 bits of precision),Interval(5.05514570748937910113e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]
[Interval(4.41728143876593134875e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.03212017903231526256e-01 with 64 bits of precision,5.05514570748937910167e-01 with 64 bits of precision)]
[Interval(4.41728143876593134875e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision),Interval(5.05514570748937910113e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)]
In [53]:
import Base.show
show(io::IO, x::Interval) = print(io, "[$(round(float(x.lo), 5)), $(x.hi)]")
Out[53]:
show (generic function with 90 methods)
In [79]:
y = bisect(x)
after_newton = [N(f,x) for x in y]
x => Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision)
Out[79]:
4-element Array{Any,1}:
[Interval(3.47097933805788840721e-01 with 64 bits of precision,6.56963251841997641835e-01 with 64 bits of precision),Interval(3.62024498772001572446e-01 with 64 bits of precision,5.68601377462807439783e-01 with 64 bits of precision)]
[Interval(3.47097933805788839555e-01 with 64 bits of precision,6.45856424941334515417e-01 with 64 bits of precision),Interval(3.69429050039110323301e-01 with 64 bits of precision,5.68601377462807440108e-01 with 64 bits of precision)]
[Interval(3.48964360037304871157e-01 with 64 bits of precision,6.41213649073018553885e-01 with 64 bits of precision),Interval(3.72524233951320964331e-01 with 64 bits of precision,5.67357093308463419131e-01 with 64 bits of precision)]
[Interval(3.36248746659157818085e-01 with 64 bits of precision,6.43246950176062365161e-01 with 64 bits of precision),Interval(3.71168699882625089759e-01 with 64 bits of precision,5.75834168893894787701e-01 with 64 bits of precision)]
In [82]:
display(y[1])
display(after_newton[1])
2-element Array{Interval,1}:
Interval(4.38274314608033558954e-01 with 64 bits of precision,4.41728143876593134902e-01 with 64 bits of precision)
Interval(5.03212017903231526256e-01 with 64 bits of precision,5.05514570748937910167e-01 with 64 bits of precision)
2-element Array{Interval,1}:
Interval(3.47097933805788840721e-01 with 64 bits of precision,6.56963251841997641835e-01 with 64 bits of precision)
Interval(3.62024498772001572446e-01 with 64 bits of precision,5.68601377462807439783e-01 with 64 bits of precision)
In [55]:
x
Out[55]:
2-element Array{Interval,1}:
Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision)
Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)
In [83]:
f(x)
Out[83]:
2-element Array{Interval,1}:
Interval(-4.19940929233143423632e-01 with 64 bits of precision,7.49196193356633135163e-01 with 64 bits of precision)
Interval(-1.38153170742383035755e-03 with 64 bits of precision,1.38153170742383035755e-03 with 64 bits of precision)
In [84]:
using NewtonMethod
Syntax: newton(function, Interval(lo, hi), precision [default is 64])
In [85]:
using KrawczykMethod
Syntax: krawczyk(function, Interval(lo, hi), precision [default is 64])
In [86]:
x
Out[86]:
2-element Array{Interval,1}:
Interval(4.38274314608033558954e-01 with 64 bits of precision,4.45181973145152710768e-01 with 64 bits of precision)
Interval(5.03212017903231526256e-01 with 64 bits of precision,5.07817123594644293915e-01 with 64 bits of precision)
In [ ]:
Content source: kriukov/interval-methods
Similar notebooks: