In [1]:
# Krawczyk 2D actually works, but when the intervals are large, it stalls
In [6]:
include("krawczyk2d.jl")
Out[6]:
In [3]:
f(x) = [x[1]^2 + x[2]^2 - 1, x[1] - x[2]^2]
Out[3]:
In [4]:
a = [Interval(0.5, 0.8), Interval(0.6, 0.9)]
Out[4]:
In [6]:
krawczyk2d(f, a)
Out[6]:
In [7]:
# Works. Now let's increase starting intervals
In [8]:
a = [Interval(0, 2), Interval(0, 2)]
Out[8]:
In [1]:
# This will set the algorithm into an infinite loop.
In [2]:
# Let's see the next example: it actually does find the roots, but when the intervals are very small
In [3]:
f(x) = [20 - 20x[1] - x[2], x[1] - x[2]/20 - 1e-9*exp(x[2]/0.052)]
Out[3]:
In [4]:
# trueroots = [0.9464142468335176, 1.0717150633296477]
In [7]:
a = [Interval(0.94, 0.95), Interval(1.05, 1.08)]
Out[7]:
In [8]:
krawczyk2d(f, a)
Out[8]:
In [9]:
# In the next function it finds the root, but only when it is closely surrounded by a starting interval
In [10]:
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[10]:
In [11]:
# trueroots = [0.06263595920972119, 0.758242693860186]
# trueroots = [0.8844295888702942, 0.21038027408647064]
# trueroots = [0.2853687241300338, 0.6097541839133109]
In [12]:
a = [Interval(0.05, 0.1), Interval(-100, 100)]
Out[12]:
In [13]:
krawczyk2d(f, a)
Out[13]:
Increasing the first interval destroys the root finding capability, and the second one in this example doesn't seem to affect it.