In [3]:
using KrawczykMethod
Syntax: krawczyk(function, Interval(lo, hi), precision)
In [4]:
compose(f::Function, g::Function) = x -> f(g(x))
Out[4]:
compose (generic function with 1 method)
In [5]:
T1(x) = Interval(r)*(Interval(1/4)-(x-Interval(1/2))^2)
Out[5]:
T1 (generic function with 1 method)
In [6]:
function T(x, p)
F = T1
for i = 1:p-1
F = compose(F, T1)
end
return F(x)
end
Out[6]:
T (generic function with 1 method)
In [7]:
f(x, p) = T(x, p) - x
Out[7]:
f (generic function with 1 method)
In [8]:
r = 3.75
Out[8]:
3.75
In [7]:
g(x) = f(x, 8)
Out[7]:
g (generic function with 1 method)
In [8]:
krawczyk(g, Interval(0, 1), 64)
Unique zero in Interval(-2.29254917138663672421e-18 with 64 bits of precision,8.06921859378946144698e-19 with 64 bits of precision)
Unique zero in Interval(2.72091791286888726398e-01 with 64 bits of precision,2.72091791286888731304e-01 with 64 bits of precision)
Unique zero in Interval(2.76480955175225120524e-01 with 64 bits of precision,2.7648095517522512524e-01 with 64 bits of precision)
Unique zero in Interval(3.04417842720349137288e-01 with 64 bits of precision,3.04417842720349140622e-01 with 64 bits of precision)
Unique zero in Interval(3.12181343990371872895e-01 with 64 bits of precision,3.12181343990371876147e-01 with 64 bits of precision)
Unique zero in Interval(3.68858764180173220252e-01 with 64 bits of precision,3.68858764180173228709e-01 with 64 bits of precision)
Unique zero in Interval(3.81672185490975005733e-01 with 64 bits of precision,3.81672185490975014515e-01 with 64 bits of precision)
Unique zero in Interval(4.15745517511237923499e-01 with 64 bits of precision,4.15745517511237931062e-01 with 64 bits of precision)
Unique zero in Interval(4.31389579128467694712e-01 with 64 bits of precision,4.31389579128467702654e-01 with 64 bits of precision)
Unique zero in Interval(5.65850590429402133341e-01 with 64 bits of precision,5.65850590429402140605e-01 with 64 bits of precision)
Unique zero in Interval(5.88162955457358919227e-01 with 64 bits of precision,5.88162955457358926925e-01 with 64 bits of precision)
Unique zero in Interval(6.13246858397271316478e-01 with 64 bits of precision,6.13246858397271324447e-01 with 64 bits of precision)
Unique zero in Interval(6.36750082098255577195e-01 with 64 bits of precision,6.36750082098255584947e-01 with 64 bits of precision)
Unique zero in Interval(6.80877960174473193498e-01 with 64 bits of precision,6.80877960174473202009e-01 with 64 bits of precision)
Unique zero in Interval(7.02849036466747324802e-01 with 64 bits of precision,7.02849036466747335318e-01 with 64 bits of precision)
Unique zero in Interval(7.16581841854029760091e-01 with 64 bits of precision,7.16581841854029763235e-01 with 64 bits of precision)
Unique zero in Interval(7.33333333333333331342e-01 with 64 bits of precision,7.33333333333333335462e-01 with 64 bits of precision)
Unique zero in Interval(7.4271693150442841708e-01 with 64 bits of precision,7.42716931504428421037e-01 with 64 bits of precision)
Unique zero in Interval(7.50147137252326044483e-01 with 64 bits of precision,7.5014713725232604844e-01 with 64 bits of precision)
Unique zero in Interval(7.61596146671685152966e-01 with 64 bits of precision,7.61596146671685163645e-01 with 64 bits of precision)
Unique zero in Interval(7.83196006516920792645e-01 with 64 bits of precision,7.8319600651692079606e-01 with 64 bits of precision)
Unique zero in Interval(7.9405357407689217456e-01 with 64 bits of precision,7.94053574076892178192e-01 with 64 bits of precision)
Unique zero in Interval(8.05215571705263676093e-01 with 64 bits of precision,8.05215571705263679779e-01 with 64 bits of precision)
Unique zero in Interval(8.14811863211706327429e-01 with 64 bits of precision,8.14811863211706330844e-01 with 64 bits of precision)
Unique zero in Interval(8.67372806422951341421e-01 with 64 bits of precision,8.67372806422951346029e-01 with 64 bits of precision)
Unique zero in Interval(8.73007411003682183451e-01 with 64 bits of precision,8.73007411003682188058e-01 with 64 bits of precision)
Unique zero in Interval(8.84994481175691653709e-01 with 64 bits of precision,8.84994481175691659401e-01 with 64 bits of precision)
Unique zero in Interval(8.89406808986806415938e-01 with 64 bits of precision,8.89406808986806421467e-01 with 64 bits of precision)
Unique zero in Interval(9.08352349818839045282e-01 with 64 bits of precision,9.08352349818839053413e-01 with 64 bits of precision)
Unique zero in Interval(9.10879433177065815912e-01 with 64 bits of precision,9.10879433177065824423e-01 with 64 bits of precision)
Unique zero in Interval(9.19847288054367015573e-01 with 64 bits of precision,9.19847288054367019205e-01 with 64 bits of precision)
Unique zero in Interval(9.2123887402537174248e-01 with 64 bits of precision,9.2123887402537174622e-01 with 64 bits of precision)
Out[8]:
32-element Array{Interval,1}:
Interval(-2.29254917138663672421e-18 with 64 bits of precision,8.06921859378946144698e-19 with 64 bits of precision)
Interval(2.72091791286888726398e-01 with 64 bits of precision,2.72091791286888731304e-01 with 64 bits of precision)
Interval(2.76480955175225120524e-01 with 64 bits of precision,2.7648095517522512524e-01 with 64 bits of precision)
Interval(3.04417842720349137288e-01 with 64 bits of precision,3.04417842720349140622e-01 with 64 bits of precision)
Interval(3.12181343990371872895e-01 with 64 bits of precision,3.12181343990371876147e-01 with 64 bits of precision)
Interval(3.68858764180173220252e-01 with 64 bits of precision,3.68858764180173228709e-01 with 64 bits of precision)
Interval(3.81672185490975005733e-01 with 64 bits of precision,3.81672185490975014515e-01 with 64 bits of precision)
Interval(4.15745517511237923499e-01 with 64 bits of precision,4.15745517511237931062e-01 with 64 bits of precision)
Interval(4.31389579128467694712e-01 with 64 bits of precision,4.31389579128467702654e-01 with 64 bits of precision)
Interval(5.65850590429402133341e-01 with 64 bits of precision,5.65850590429402140605e-01 with 64 bits of precision)
Interval(5.88162955457358919227e-01 with 64 bits of precision,5.88162955457358926925e-01 with 64 bits of precision)
Interval(6.13246858397271316478e-01 with 64 bits of precision,6.13246858397271324447e-01 with 64 bits of precision)
Interval(6.36750082098255577195e-01 with 64 bits of precision,6.36750082098255584947e-01 with 64 bits of precision)
⋮
Interval(7.83196006516920792645e-01 with 64 bits of precision,7.8319600651692079606e-01 with 64 bits of precision)
Interval(7.9405357407689217456e-01 with 64 bits of precision,7.94053574076892178192e-01 with 64 bits of precision)
Interval(8.05215571705263676093e-01 with 64 bits of precision,8.05215571705263679779e-01 with 64 bits of precision)
Interval(8.14811863211706327429e-01 with 64 bits of precision,8.14811863211706330844e-01 with 64 bits of precision)
Interval(8.67372806422951341421e-01 with 64 bits of precision,8.67372806422951346029e-01 with 64 bits of precision)
Interval(8.73007411003682183451e-01 with 64 bits of precision,8.73007411003682188058e-01 with 64 bits of precision)
Interval(8.84994481175691653709e-01 with 64 bits of precision,8.84994481175691659401e-01 with 64 bits of precision)
Interval(8.89406808986806415938e-01 with 64 bits of precision,8.89406808986806421467e-01 with 64 bits of precision)
Interval(9.08352349818839045282e-01 with 64 bits of precision,9.08352349818839053413e-01 with 64 bits of precision)
Interval(9.10879433177065815912e-01 with 64 bits of precision,9.10879433177065824423e-01 with 64 bits of precision)
Interval(9.19847288054367015573e-01 with 64 bits of precision,9.19847288054367019205e-01 with 64 bits of precision)
Interval(9.2123887402537174248e-01 with 64 bits of precision,9.2123887402537174622e-01 with 64 bits of precision)
In [9]:
g(x) = f(x, 10)
Out[9]:
g (generic function with 1 method)
In [10]:
krawczyk(g, Interval(0, 1), 64)
Unique zero in Interval(-7.96810895333733385633e-18 with 64 bits of precision,2.71694903911410001286e-18 with 64 bits of precision)
Unique zero in Interval(2.23164787935443086653e-01 with 64 bits of precision,2.23164787935443090447e-01 with 64 bits of precision)
Unique zero in Interval(2.24717442522161132103e-01 with 64 bits of precision,2.24717442522161135626e-01 with 64 bits of precision)
Unique zero in Interval(2.30605790099317103264e-01 with 64 bits of precision,2.30605790099317110216e-01 with 64 bits of precision)
Unique zero in Interval(2.33219105323944230987e-01 with 64 bits of precision,2.33219105323944240812e-01 with 64 bits of precision)
Unique zero in Interval(2.68457429305722437542e-01 with 64 bits of precision,2.68457429305722441472e-01 with 64 bits of precision)
Unique zero in Interval(2.69807923107789967719e-01 with 64 bits of precision,2.69807923107789971459e-01 with 64 bits of precision)
Unique zero in Interval(2.78986886979055745232e-01 with 64 bits of precision,2.78986886979055755939e-01 with 64 bits of precision)
Unique zero in Interval(2.809873148959096226e-01 with 64 bits of precision,2.80987314895909632873e-01 with 64 bits of precision)
Unique zero in Interval(2.99439306561133542872e-01 with 64 bits of precision,2.99439306561133551031e-01 with 64 bits of precision)
Unique zero in Interval(3.02218319687736797815e-01 with 64 bits of precision,3.02218319687736806055e-01 with 64 bits of precision)
Unique zero in Interval(3.14198669778016665397e-01 with 64 bits of precision,3.14198669778016672797e-01 with 64 bits of precision)
Unique zero in Interval(3.17409338856421526377e-01 with 64 bits of precision,3.17409338856421533695e-01 with 64 bits of precision)
Unique zero in Interval(3.63792338241075446291e-01 with 64 bits of precision,3.63792338241075452254e-01 with 64 bits of precision)
Unique zero in Interval(3.68446253724655161359e-01 with 64 bits of precision,3.68446253724655167322e-01 with 64 bits of precision)
Unique zero in Interval(3.81672185490975006899e-01 with 64 bits of precision,3.81672185490975012618e-01 with 64 bits of precision)
Unique zero in Interval(3.86919530042819549107e-01 with 64 bits of precision,3.86919530042819554528e-01 with 64 bits of precision)
Unique zero in Interval(4.10845646607665049245e-01 with 64 bits of precision,4.10845646607665054584e-01 with 64 bits of precision)
Unique zero in Interval(4.16881731410445553065e-01 with 64 bits of precision,4.16881731410445558486e-01 with 64 bits of precision)
Unique zero in Interval(4.29858636283553983038e-01 with 64 bits of precision,4.29858636283553988431e-01 with 64 bits of precision)
Unique zero in Interval(4.3562849480899037765e-01 with 64 bits of precision,4.35628494808990383695e-01 with 64 bits of precision)
Unique zero in Interval(4.7020857522180411632e-01 with 64 bits of precision,4.70208575221804120711e-01 with 64 bits of precision)
Unique zero in Interval(4.79842729207712715637e-01 with 64 bits of precision,4.79842729207712721546e-01 with 64 bits of precision)
Unique zero in Interval(5.16726011429398538312e-01 with 64 bits of precision,5.16726011429398546877e-01 with 64 bits of precision)
Unique zero in Interval(5.33192453006087834844e-01 with 64 bits of precision,5.3319245300608784509e-01 with 64 bits of precision)
Unique zero in Interval(5.63481903009224140719e-01 with 64 bits of precision,5.63481903009224146682e-01 with 64 bits of precision)
Unique zero in Interval(5.7134193738000762662e-01 with 64 bits of precision,5.71341937380007632149e-01 with 64 bits of precision)
Unique zero in Interval(5.81662981866095525911e-01 with 64 bits of precision,5.81662981866095531278e-01 with 64 bits of precision)
Unique zero in Interval(5.90713106646597251438e-01 with 64 bits of precision,5.90713106646597256588e-01 with 64 bits of precision)
Unique zero in Interval(6.11190272873419429979e-01 with 64 bits of precision,6.11190272873419435128e-01 with 64 bits of precision)
Unique zero in Interval(6.20362913992382505033e-01 with 64 bits of precision,6.20362913992382510671e-01 with 64 bits of precision)
Unique zero in Interval(6.29352437376554497018e-01 with 64 bits of precision,6.29352437376554502276e-01 with 64 bits of precision)
Unique zero in Interval(6.38245086263208395716e-01 with 64 bits of precision,6.38245086263208401245e-01 with 64 bits of precision)
Unique zero in Interval(6.50108495104394259719e-01 with 64 bits of precision,6.50108495104394267091e-01 with 64 bits of precision)
Unique zero in Interval(6.5332317580672627478e-01 with 64 bits of precision,6.53323175806726281448e-01 with 64 bits of precision)
Unique zero in Interval(6.65350348769950523714e-01 with 64 bits of precision,6.65350348769950528593e-01 with 64 bits of precision)
Unique zero in Interval(6.70604828384412151828e-01 with 64 bits of precision,6.70604828384412158062e-01 with 64 bits of precision)
Unique zero in Interval(6.80138104063306868602e-01 with 64 bits of precision,6.80138104063306874727e-01 with 64 bits of precision)
Unique zero in Interval(6.88609297511428190624e-01 with 64 bits of precision,6.88609297511428197129e-01 with 64 bits of precision)
Unique zero in Interval(6.94946404922463414845e-01 with 64 bits of precision,6.94946404922463421513e-01 with 64 bits of precision)
Unique zero in Interval(7.03311742841305898803e-01 with 64 bits of precision,7.03311742841305905416e-01 with 64 bits of precision)
Unique zero in Interval(7.16349733140606362563e-01 with 64 bits of precision,7.16349733140606369664e-01 with 64 bits of precision)
Unique zero in Interval(7.23666189385721965444e-01 with 64 bits of precision,7.23666189385721973792e-01 with 64 bits of precision)
Unique zero in Interval(7.27833621235607318434e-01 with 64 bits of precision,7.27833621235607327324e-01 with 64 bits of precision)
Unique zero in Interval(7.33333333333333331559e-01 with 64 bits of precision,7.33333333333333334811e-01 with 64 bits of precision)
Unique zero in Interval(7.36455142336070542591e-01 with 64 bits of precision,7.36455142336070545789e-01 with 64 bits of precision)
Unique zero in Interval(7.38793529010190737989e-01 with 64 bits of precision,7.38793529010190748777e-01 with 64 bits of precision)
Unique zero in Interval(7.42844403880011821086e-01 with 64 bits of precision,7.42844403880011829163e-01 with 64 bits of precision)
Unique zero in Interval(7.49900383971263819231e-01 with 64 bits of precision,7.4990038397126382682e-01 with 64 bits of precision)
Unique zero in Interval(7.54324514522967459274e-01 with 64 bits of precision,7.5432451452296746811e-01 with 64 bits of precision)
Unique zero in Interval(7.57625414113112061285e-01 with 64 bits of precision,7.57625414113112070067e-01 with 64 bits of precision)
Unique zero in Interval(7.61972973637456539467e-01 with 64 bits of precision,7.61972973637456546731e-01 with 64 bits of precision)
Unique zero in Interval(7.82491257085615114287e-01 with 64 bits of precision,7.82491257085615121768e-01 with 64 bits of precision)
Unique zero in Interval(7.86657780927453861809e-01 with 64 bits of precision,7.86657780927453870103e-01 with 64 bits of precision)
Unique zero in Interval(7.90809025998216445883e-01 with 64 bits of precision,7.90809025998216454285e-01 with 64 bits of precision)
Unique zero in Interval(7.9498462202927598695e-01 with 64 bits of precision,7.94984622029275994376e-01 with 64 bits of precision)
Unique zero in Interval(8.04099498345920869844e-01 with 64 bits of precision,8.04099498345920877542e-01 with 64 bits of precision)
Unique zero in Interval(8.08041996329030635037e-01 with 64 bits of precision,8.08041996329030643494e-01 with 64 bits of precision)
Unique zero in Interval(8.12477439236815883591e-01 with 64 bits of precision,8.12477439236815892373e-01 with 64 bits of precision)
Unique zero in Interval(8.15813487991789587357e-01 with 64 bits of precision,8.15813487991789596139e-01 with 64 bits of precision)
Unique zero in Interval(8.28352471994719785468e-01 with 64 bits of precision,8.28352471994719791214e-01 with 64 bits of precision)
Unique zero in Interval(8.34972233106208949554e-01 with 64 bits of precision,8.3497223310620895427e-01 with 64 bits of precision)
Unique zero in Interval(8.49345014102023893119e-01 with 64 bits of precision,8.49345014102023899624e-01 with 64 bits of precision)
Unique zero in Interval(8.53002898865602660419e-01 with 64 bits of precision,8.53002898865602667466e-01 with 64 bits of precision)
Unique zero in Interval(8.65831110465292755156e-01 with 64 bits of precision,8.6583111046529275868e-01 with 64 bits of precision)
Unique zero in Interval(8.67928023293124008015e-01 with 64 bits of precision,8.67928023293124011376e-01 with 64 bits of precision)
Unique zero in Interval(8.72601044403458228529e-01 with 64 bits of precision,8.72601044403458231944e-01 with 64 bits of precision)
Unique zero in Interval(8.74754801042792047919e-01 with 64 bits of precision,8.74754801042792051117e-01 with 64 bits of precision)
Unique zero in Interval(8.83172883507233739801e-01 with 64 bits of precision,8.83172883507233743433e-01 with 64 bits of precision)
Unique zero in Interval(8.84994481175691654902e-01 with 64 bits of precision,8.84994481175691658642e-01 with 64 bits of precision)
Unique zero in Interval(8.89548027428487035563e-01 with 64 bits of precision,8.89548027428487039629e-01 with 64 bits of precision)
Unique zero in Interval(8.91137712068754473272e-01 with 64 bits of precision,8.91137712068754477121e-01 with 64 bits of precision)
Unique zero in Interval(9.06641746059461520939e-01 with 64 bits of precision,9.06641746059461526143e-01 with 64 bits of precision)
Unique zero in Interval(9.07693129766979949738e-01 with 64 bits of precision,9.07693129766979954942e-01 with 64 bits of precision)
Unique zero in Interval(9.11592575350030073409e-01 with 64 bits of precision,9.11592575350030079426e-01 with 64 bits of precision)
Unique zero in Interval(9.12491840222766570237e-01 with 64 bits of precision,9.124918402227665762e-01 with 64 bits of precision)
Unique zero in Interval(9.18413729890751509035e-01 with 64 bits of precision,9.18413729890751516678e-01 with 64 bits of precision)
Unique zero in Interval(9.19050709109989611833e-01 with 64 bits of precision,9.19050709109989619747e-01 with 64 bits of precision)
Unique zero in Interval(9.21961159947914325741e-01 with 64 bits of precision,9.21961159947914336257e-01 with 64 bits of precision)
Unique zero in Interval(9.22387679963727968294e-01 with 64 bits of precision,9.22387679963727971329e-01 with 64 bits of precision)
Unique zero in Interval(9.33368478987894934862e-01 with 64 bits of precision,9.33368478987894942831e-01 with 64 bits of precision)
Unique zero in Interval(9.34171766286319109091e-01 with 64 bits of precision,9.3417176628631911462e-01 with 64 bits of precision)
Unique zero in Interval(9.35976316628274002238e-01 with 64 bits of precision,9.35976316628274011182e-01 with 64 bits of precision)
Unique zero in Interval(9.36450902031238608498e-01 with 64 bits of precision,9.36450902031238611642e-01 with 64 bits of precision)
Out[10]:
84-element Array{Interval,1}:
Interval(-7.96810895333733385633e-18 with 64 bits of precision,2.71694903911410001286e-18 with 64 bits of precision)
Interval(2.23164787935443086653e-01 with 64 bits of precision,2.23164787935443090447e-01 with 64 bits of precision)
Interval(2.24717442522161132103e-01 with 64 bits of precision,2.24717442522161135626e-01 with 64 bits of precision)
Interval(2.30605790099317103264e-01 with 64 bits of precision,2.30605790099317110216e-01 with 64 bits of precision)
Interval(2.33219105323944230987e-01 with 64 bits of precision,2.33219105323944240812e-01 with 64 bits of precision)
Interval(2.68457429305722437542e-01 with 64 bits of precision,2.68457429305722441472e-01 with 64 bits of precision)
Interval(2.69807923107789967719e-01 with 64 bits of precision,2.69807923107789971459e-01 with 64 bits of precision)
Interval(2.78986886979055745232e-01 with 64 bits of precision,2.78986886979055755939e-01 with 64 bits of precision)
Interval(2.809873148959096226e-01 with 64 bits of precision,2.80987314895909632873e-01 with 64 bits of precision)
Interval(2.99439306561133542872e-01 with 64 bits of precision,2.99439306561133551031e-01 with 64 bits of precision)
Interval(3.02218319687736797815e-01 with 64 bits of precision,3.02218319687736806055e-01 with 64 bits of precision)
Interval(3.14198669778016665397e-01 with 64 bits of precision,3.14198669778016672797e-01 with 64 bits of precision)
Interval(3.17409338856421526377e-01 with 64 bits of precision,3.17409338856421533695e-01 with 64 bits of precision)
⋮
Interval(9.06641746059461520939e-01 with 64 bits of precision,9.06641746059461526143e-01 with 64 bits of precision)
Interval(9.07693129766979949738e-01 with 64 bits of precision,9.07693129766979954942e-01 with 64 bits of precision)
Interval(9.11592575350030073409e-01 with 64 bits of precision,9.11592575350030079426e-01 with 64 bits of precision)
Interval(9.12491840222766570237e-01 with 64 bits of precision,9.124918402227665762e-01 with 64 bits of precision)
Interval(9.18413729890751509035e-01 with 64 bits of precision,9.18413729890751516678e-01 with 64 bits of precision)
Interval(9.19050709109989611833e-01 with 64 bits of precision,9.19050709109989619747e-01 with 64 bits of precision)
Interval(9.21961159947914325741e-01 with 64 bits of precision,9.21961159947914336257e-01 with 64 bits of precision)
Interval(9.22387679963727968294e-01 with 64 bits of precision,9.22387679963727971329e-01 with 64 bits of precision)
Interval(9.33368478987894934862e-01 with 64 bits of precision,9.33368478987894942831e-01 with 64 bits of precision)
Interval(9.34171766286319109091e-01 with 64 bits of precision,9.3417176628631911462e-01 with 64 bits of precision)
Interval(9.35976316628274002238e-01 with 64 bits of precision,9.35976316628274011182e-01 with 64 bits of precision)
Interval(9.36450902031238608498e-01 with 64 bits of precision,9.36450902031238611642e-01 with 64 bits of precision)
In [11]:
krawczyk(g, Interval(0, 1), 128)
Unique zero in Interval(-4.311961097452756814681580377462456565265e-37 with 128 bits of precision,1.460488565847413407917706474100813571642e-37 with 128 bits of precision)
Unique zero in Interval(2.231647879354430888238462485067530366455e-01 with 128 bits of precision,2.23164787935443088823846248506753036849e-01 with 128 bits of precision)
Unique zero in Interval(2.247174425221611335775939175100521546397e-01 with 128 bits of precision,2.247174425221611335775939175100521548292e-01 with 128 bits of precision)
Unique zero in Interval(2.306057900993171066697149343149083031586e-01 with 128 bits of precision,2.306057900993171066697149343149083035428e-01 with 128 bits of precision)
Unique zero in Interval(2.332191053239442357471664350447304135035e-01 with 128 bits of precision,2.332191053239442357471664350447304140449e-01 with 128 bits of precision)
Unique zero in Interval(2.684574293057224400295068068790988586037e-01 with 128 bits of precision,2.684574293057224400295068068790988588226e-01 with 128 bits of precision)
Unique zero in Interval(2.698079231077899693536919858778720677066e-01 with 128 bits of precision,2.698079231077899693536919858778720679137e-01 with 128 bits of precision)
Unique zero in Interval(2.789868869790557511807365021881286112363e-01 with 128 bits of precision,2.789868869790557511807365021881286118108e-01 with 128 bits of precision)
Unique zero in Interval(2.80987314895909627026080351766693342159e-01 with 128 bits of precision,2.809873148959096270260803517666933427159e-01 with 128 bits of precision)
Unique zero in Interval(2.994393065611335470528501536454260438162e-01 with 128 bits of precision,2.994393065611335470528501536454260442526e-01 with 128 bits of precision)
Unique zero in Interval(3.022183196877368018780204121935791261627e-01 with 128 bits of precision,3.022183196877368018780204121935791266093e-01 with 128 bits of precision)
Unique zero in Interval(3.141986697780166692254233701144997204551e-01 with 128 bits of precision,3.141986697780166692254233701144997208547e-01 with 128 bits of precision)
Unique zero in Interval(3.17409338856421529954142778201083344954e-01 with 128 bits of precision,3.174093388564215299541427782010833453581e-01 with 128 bits of precision)
Unique zero in Interval(3.637923382410754492917513254068127795314e-01 with 128 bits of precision,3.637923382410754492917513254068127798561e-01 with 128 bits of precision)
Unique zero in Interval(3.684462537246551641826129411611654734252e-01 with 128 bits of precision,3.68446253724655164182612941161165473744e-01 with 128 bits of precision)
Unique zero in Interval(3.816721854909750100921105064351294312274e-01 with 128 bits of precision,3.816721854909750100921105064351294315315e-01 with 128 bits of precision)
Unique zero in Interval(3.869195300428195518256653765600113108547e-01 with 128 bits of precision,3.869195300428195518256653765600113111485e-01 with 128 bits of precision)
Unique zero in Interval(4.108456466076650520165595819162808104065e-01 with 128 bits of precision,4.108456466076650520165595819162808106857e-01 with 128 bits of precision)
Unique zero in Interval(4.168817314104455558383228136076291410575e-01 with 128 bits of precision,4.168817314104455558383228136076291413499e-01 with 128 bits of precision)
Unique zero in Interval(4.298586362835539857384989507094470588497e-01 with 128 bits of precision,4.29858636283553985738498950709447059145e-01 with 128 bits of precision)
Unique zero in Interval(4.356284948089903807261489669756523641537e-01 with 128 bits of precision,4.356284948089903807261489669756523644652e-01 with 128 bits of precision)
Unique zero in Interval(4.702085752218041185521770083295219951456e-01 with 128 bits of precision,4.702085752218041185521770083295219953969e-01 with 128 bits of precision)
Unique zero in Interval(4.798427292077127182198358631911996620954e-01 with 128 bits of precision,4.798427292077127182198358631911996626596e-01 with 128 bits of precision)
Unique zero in Interval(5.167260114293985426579644246833308785219e-01 with 128 bits of precision,5.16726011429398542657964424683330878995e-01 with 128 bits of precision)
Unique zero in Interval(5.331924530060878392510725799806186491353e-01 with 128 bits of precision,5.331924530060878392510725799806186496995e-01 with 128 bits of precision)
Unique zero in Interval(5.634819030092241435946193935200824035191e-01 with 128 bits of precision,5.634819030092241435946193935200824038247e-01 with 128 bits of precision)
Unique zero in Interval(5.713419373800076294705970751347270746696e-01 with 128 bits of precision,5.713419373800076294705970751347270749634e-01 with 128 bits of precision)
Unique zero in Interval(5.816629818660955284992868594678972043595e-01 with 128 bits of precision,5.816629818660955284992868594678972046563e-01 with 128 bits of precision)
Unique zero in Interval(5.907131066465972539431688832096141220521e-01 with 128 bits of precision,5.907131066465972539431688832096141223371e-01 with 128 bits of precision)
Unique zero in Interval(6.111902728734194324834105783501908356227e-01 with 128 bits of precision,6.111902728734194324834105783501908358989e-01 with 128 bits of precision)
Unique zero in Interval(6.203629139923825078865052351400758220658e-01 with 128 bits of precision,6.203629139923825078865052351400758223655e-01 with 128 bits of precision)
Unique zero in Interval(6.293524373765544996826042493878262803e-01 with 128 bits of precision,6.293524373765544996826042493878262805997e-01 with 128 bits of precision)
Unique zero in Interval(6.38245086263208398517520400701262932342e-01 with 128 bits of precision,6.382450862632083985175204007012629326476e-01 with 128 bits of precision)
Unique zero in Interval(6.501084951043942635480038210285156832185e-01 with 128 bits of precision,6.501084951043942635480038210285156836152e-01 with 128 bits of precision)
Unique zero in Interval(6.533231758067262780232021529091690659461e-01 with 128 bits of precision,6.533231758067262780232021529091690663134e-01 with 128 bits of precision)
Unique zero in Interval(6.653503487699505261438123136225863468123e-01 with 128 bits of precision,6.653503487699505261438123136225863470709e-01 with 128 bits of precision)
Unique zero in Interval(6.706048283844121544268759098871350460222e-01 with 128 bits of precision,6.706048283844121544268759098871350463513e-01 with 128 bits of precision)
Unique zero in Interval(6.801381040633068716322925315122517178637e-01 with 128 bits of precision,6.801381040633068716322925315122517182046e-01 with 128 bits of precision)
Unique zero in Interval(6.886092975114281942907684668490665200749e-01 with 128 bits of precision,6.886092975114281942907684668490665204246e-01 with 128 bits of precision)
Unique zero in Interval(6.949464049224634180469433023552794634773e-01 with 128 bits of precision,6.949464049224634180469433023552794638387e-01 with 128 bits of precision)
Unique zero in Interval(7.033117428413059023012890138073416622043e-01 with 128 bits of precision,7.033117428413059023012890138073416625569e-01 with 128 bits of precision)
Unique zero in Interval(7.163497331406063660254289510062972460575e-01 with 128 bits of precision,7.163497331406063660254289510062972464395e-01 with 128 bits of precision)
Unique zero in Interval(7.236661893857219698571419685697112263277e-01 with 128 bits of precision,7.236661893857219698571419685697112267861e-01 with 128 bits of precision)
Unique zero in Interval(7.278336212356073226496882593928882625555e-01 with 128 bits of precision,7.278336212356073226496882593928882630374e-01 with 128 bits of precision)
Unique zero in Interval(7.333333333333333333333333333333333332342e-01 with 128 bits of precision,7.333333333333333333333333333333333334164e-01 with 128 bits of precision)
Unique zero in Interval(7.364551423360705442256916256849200717615e-01 with 128 bits of precision,7.364551423360705442256916256849200719466e-01 with 128 bits of precision)
Unique zero in Interval(7.387935290101907431461252532563533312662e-01 with 128 bits of precision,7.387935290101907431461252532563533318392e-01 with 128 bits of precision)
Unique zero in Interval(7.42844403880011825141381030736903892023e-01 with 128 bits of precision,7.42844403880011825141381030736903892452e-01 with 128 bits of precision)
Unique zero in Interval(7.499003839712638231056709683211345529738e-01 with 128 bits of precision,7.49900383971263823105670968321134553394e-01 with 128 bits of precision)
Unique zero in Interval(7.543245145229674640159150190152100437416e-01 with 128 bits of precision,7.543245145229674640159150190152100442206e-01 with 128 bits of precision)
Unique zero in Interval(7.576254141131120657018476499493236363201e-01 with 128 bits of precision,7.576254141131120657018476499493236367932e-01 with 128 bits of precision)
Unique zero in Interval(7.619729736374565430680982511690929427984e-01 with 128 bits of precision,7.619729736374565430680982511690929431892e-01 with 128 bits of precision)
Unique zero in Interval(7.824912570856151182075898335040571497432e-01 with 128 bits of precision,7.824912570856151182075898335040571501458e-01 with 128 bits of precision)
Unique zero in Interval(7.866577809274538659962438950930750896073e-01 with 128 bits of precision,7.866577809274538659962438950930750900539e-01 with 128 bits of precision)
Unique zero in Interval(7.908090259982164501838090981044141995502e-01 with 128 bits of precision,7.908090259982164501838090981044142000086e-01 with 128 bits of precision)
Unique zero in Interval(7.949846220292759905354774089739652273365e-01 with 128 bits of precision,7.94984622029275990535477408973965227742e-01 with 128 bits of precision)
Unique zero in Interval(8.040994983459208738354451019005381142312e-01 with 128 bits of precision,8.040994983459208738354451019005381146455e-01 with 128 bits of precision)
Unique zero in Interval(8.080419963290306390971157430710156280951e-01 with 128 bits of precision,8.080419963290306390971157430710156285535e-01 with 128 bits of precision)
Unique zero in Interval(8.124774392368158880398813077231822934149e-01 with 128 bits of precision,8.124774392368158880398813077231822938968e-01 with 128 bits of precision)
Unique zero in Interval(8.158134879917895912898766865156670521716e-01 with 128 bits of precision,8.158134879917895912898766865156670526359e-01 with 128 bits of precision)
Unique zero in Interval(8.283524719947197882925528343560425993522e-01 with 128 bits of precision,8.283524719947197882925528343560425996519e-01 with 128 bits of precision)
Unique zero in Interval(8.349722331062089519719422215594012674689e-01 with 128 bits of precision,8.349722331062089519719422215594012676922e-01 with 128 bits of precision)
Unique zero in Interval(8.493450141020238965410970881690971276412e-01 with 128 bits of precision,8.493450141020238965410970881690971279791e-01 with 128 bits of precision)
Unique zero in Interval(8.530028988656026628004502878022133924249e-01 with 128 bits of precision,8.530028988656026628004502878022133927922e-01 with 128 bits of precision)
Unique zero in Interval(8.658311104652927570728784187991539588128e-01 with 128 bits of precision,8.65831110465292757072878418799153958995e-01 with 128 bits of precision)
Unique zero in Interval(8.679280232931240096342773834508996395297e-01 with 128 bits of precision,8.67928023293124009634277383450899639706e-01 with 128 bits of precision)
Unique zero in Interval(8.726010444034582302642027837913274255963e-01 with 128 bits of precision,8.726010444034582302642027837913274257755e-01 with 128 bits of precision)
Unique zero in Interval(8.747548010427920492388207616464053295207e-01 with 128 bits of precision,8.74754801042792049238820761646405329697e-01 with 128 bits of precision)
Unique zero in Interval(8.831728835072337416109242664692677378085e-01 with 128 bits of precision,8.831728835072337416109242664692677380024e-01 with 128 bits of precision)
Unique zero in Interval(8.849944811756916565745561602315372351711e-01 with 128 bits of precision,8.849944811756916565745561602315372353797e-01 with 128 bits of precision)
Unique zero in Interval(8.895480274284870378353913137614323052298e-01 with 128 bits of precision,8.895480274284870378353913137614323054413e-01 with 128 bits of precision)
Unique zero in Interval(8.911377120687544751298989233930759861923e-01 with 128 bits of precision,8.911377120687544751298989233930759864127e-01 with 128 bits of precision)
Unique zero in Interval(9.066417460594615241602529903856092996377e-01 with 128 bits of precision,9.066417460594615241602529903856092999168e-01 with 128 bits of precision)
Unique zero in Interval(9.076931297669799523221326933033404989186e-01 with 128 bits of precision,9.076931297669799523221326933033404991948e-01 with 128 bits of precision)
Unique zero in Interval(9.115925753500300765184359423242067052826e-01 with 128 bits of precision,9.115925753500300765184359423242067056029e-01 with 128 bits of precision)
Unique zero in Interval(9.124918402227665732768778482887044911877e-01 with 128 bits of precision,9.124918402227665732768778482887044915168e-01 with 128 bits of precision)
Unique zero in Interval(9.18413729890751512999398156640670513564e-01 with 128 bits of precision,9.184137298907515129993981566406705139754e-01 with 128 bits of precision)
Unique zero in Interval(9.190507091099896146535007422592621341197e-01 with 128 bits of precision,9.190507091099896146535007422592621345458e-01 with 128 bits of precision)
Unique zero in Interval(9.219611599479143311471714839813545923687e-01 with 128 bits of precision,9.219611599479143311471714839813545929388e-01 with 128 bits of precision)
Unique zero in Interval(9.223876799637279698326931844458416597196e-01 with 128 bits of precision,9.223876799637279698326931844458416598871e-01 with 128 bits of precision)
Unique zero in Interval(9.333684789878949388632651547202334342163e-01 with 128 bits of precision,9.333684789878949388632651547202334346424e-01 with 128 bits of precision)
Unique zero in Interval(9.34171766286319111784548173202644249921e-01 with 128 bits of precision,9.341717662863191117845481732026442502207e-01 with 128 bits of precision)
Unique zero in Interval(9.359763166282740077229868681104560227093e-01 with 128 bits of precision,9.359763166282740077229868681104560231941e-01 with 128 bits of precision)
Unique zero in Interval(9.364509020312386099494552268255956698561e-01 with 128 bits of precision,9.364509020312386099494552268255956704379e-01 with 128 bits of precision)
Out[11]:
84-element Array{Interval,1}:
Interval(-4.311961097452756814681580377462456565265e-37 with 128 bits of precision,1.460488565847413407917706474100813571642e-37 with 128 bits of precision)
Interval(2.231647879354430888238462485067530366455e-01 with 128 bits of precision,2.23164787935443088823846248506753036849e-01 with 128 bits of precision)
Interval(2.247174425221611335775939175100521546397e-01 with 128 bits of precision,2.247174425221611335775939175100521548292e-01 with 128 bits of precision)
Interval(2.306057900993171066697149343149083031586e-01 with 128 bits of precision,2.306057900993171066697149343149083035428e-01 with 128 bits of precision)
Interval(2.332191053239442357471664350447304135035e-01 with 128 bits of precision,2.332191053239442357471664350447304140449e-01 with 128 bits of precision)
Interval(2.684574293057224400295068068790988586037e-01 with 128 bits of precision,2.684574293057224400295068068790988588226e-01 with 128 bits of precision)
Interval(2.698079231077899693536919858778720677066e-01 with 128 bits of precision,2.698079231077899693536919858778720679137e-01 with 128 bits of precision)
Interval(2.789868869790557511807365021881286112363e-01 with 128 bits of precision,2.789868869790557511807365021881286118108e-01 with 128 bits of precision)
Interval(2.80987314895909627026080351766693342159e-01 with 128 bits of precision,2.809873148959096270260803517666933427159e-01 with 128 bits of precision)
Interval(2.994393065611335470528501536454260438162e-01 with 128 bits of precision,2.994393065611335470528501536454260442526e-01 with 128 bits of precision)
Interval(3.022183196877368018780204121935791261627e-01 with 128 bits of precision,3.022183196877368018780204121935791266093e-01 with 128 bits of precision)
Interval(3.141986697780166692254233701144997204551e-01 with 128 bits of precision,3.141986697780166692254233701144997208547e-01 with 128 bits of precision)
Interval(3.17409338856421529954142778201083344954e-01 with 128 bits of precision,3.174093388564215299541427782010833453581e-01 with 128 bits of precision)
⋮
Interval(9.066417460594615241602529903856092996377e-01 with 128 bits of precision,9.066417460594615241602529903856092999168e-01 with 128 bits of precision)
Interval(9.076931297669799523221326933033404989186e-01 with 128 bits of precision,9.076931297669799523221326933033404991948e-01 with 128 bits of precision)
Interval(9.115925753500300765184359423242067052826e-01 with 128 bits of precision,9.115925753500300765184359423242067056029e-01 with 128 bits of precision)
Interval(9.124918402227665732768778482887044911877e-01 with 128 bits of precision,9.124918402227665732768778482887044915168e-01 with 128 bits of precision)
Interval(9.18413729890751512999398156640670513564e-01 with 128 bits of precision,9.184137298907515129993981566406705139754e-01 with 128 bits of precision)
Interval(9.190507091099896146535007422592621341197e-01 with 128 bits of precision,9.190507091099896146535007422592621345458e-01 with 128 bits of precision)
Interval(9.219611599479143311471714839813545923687e-01 with 128 bits of precision,9.219611599479143311471714839813545929388e-01 with 128 bits of precision)
Interval(9.223876799637279698326931844458416597196e-01 with 128 bits of precision,9.223876799637279698326931844458416598871e-01 with 128 bits of precision)
Interval(9.333684789878949388632651547202334342163e-01 with 128 bits of precision,9.333684789878949388632651547202334346424e-01 with 128 bits of precision)
Interval(9.34171766286319111784548173202644249921e-01 with 128 bits of precision,9.341717662863191117845481732026442502207e-01 with 128 bits of precision)
Interval(9.359763166282740077229868681104560227093e-01 with 128 bits of precision,9.359763166282740077229868681104560231941e-01 with 128 bits of precision)
Interval(9.364509020312386099494552268255956698561e-01 with 128 bits of precision,9.364509020312386099494552268255956704379e-01 with 128 bits of precision)
In [12]:
# Testing Krawczyk2d with two examples
In [13]:
#The first one works
In [1]:
include("krawczyk2d.jl")
Out[1]:
krawczyk2d (generic function with 1 method)
In [15]:
f(x) = [x[1]^2 + x[2]^2 - 1, x[1] - x[2]^2]
Out[15]:
f (generic function with 2 methods)
In [16]:
a = [Interval(0.5, 0.8), Interval(0.6, 0.9)]
Out[16]:
2-element Array{Interval,1}:
Interval(5e-01 with 128 bits of precision,8.000000000000000000000000000000000000006e-01 with 128 bits of precision)
Interval(5.999999999999999999999999999999999999982e-01 with 128 bits of precision,9.000000000000000000000000000000000000018e-01 with 128 bits of precision)
In [17]:
krawczyk2d(f, a, 64)
a => [Interval(5e-01 with 128 bits of precision,8.000000000000000000000000000000000000006e-01 with 128 bits of precision),Interval(5.999999999999999999999999999999999999982e-01 with 128 bits of precision,9.000000000000000000000000000000000000018e-01 with 128 bits of precision)]
diam(a) => BigFloat[3.00000000000000000011e-01,3.00000000000000000011e-01]
a => [Interval(5.59782608695652173663e-01 with 64 bits of precision,6.77173913043478261178e-01 with 64 bits of precision),Interval(7.44275362318840579543e-01 with 64 bits of precision,8.30362318840579710297e-01 with 64 bits of precision)]
diam(a) => BigFloat[1.17391304347826087515e-01,8.60869565217391307537e-02]
a => [Interval(6.11640871255334431689e-01 with 64 bits of precision,6.2442728271432796749e-01 with 64 bits of precision),Interval(7.81842914150279365878e-01 with 64 bits of precision,7.90461684587798984547e-01 with 64 bits of precision)]
diam(a) => BigFloat[1.27864114589935358012e-02,8.61877043751961866925e-03]
a => [Interval(6.17964210303039719575e-01 with 64 bits of precision,6.18103767196756940291e-01 with 64 bits of precision),Interval(7.86104504147861314384e-01 with 64 bits of precision,7.86198251368070098082e-01 with 64 bits of precision)]
diam(a) => BigFloat[1.3955689371722071598e-04,9.37472202087836982594e-05]
a => [Interval(6.1803398046454539747e-01 with 64 bits of precision,6.1803399703524429889e-01 with 64 bits of precision),Interval(7.8615137219280482048e-01 with 64 bits of precision,7.86151383322041751489e-01 with 64 bits of precision)]
diam(a) => BigFloat[1.65706989014202839272e-08,1.11292369310090136225e-08]
a => [Interval(6.18033988749894731222e-01 with 64 bits of precision,6.18033988749894965084e-01 with 64 bits of precision),Interval(7.86151377757423207543e-01 with 64 bits of precision,7.86151377757423364535e-01 with 64 bits of precision)]
diam(a) => BigFloat[2.33862408605123306415e-16,1.56992474575901042044e-16]
Unique zero in [Interval(6.18033988749894848099e-01 with 64 bits of precision,6.1803398874989484837e-01 with 64 bits of precision),Interval(7.86151377757423285931e-01 with 64 bits of precision,7.86151377757423286147e-01 with 64 bits of precision)]
Out[17]:
1-element Array{Array{Interval,1},1}:
[Interval(6.18033988749894848099e-01 with 64 bits of precision,6.1803398874989484837e-01 with 64 bits of precision),Interval(7.86151377757423285931e-01 with 64 bits of precision,7.86151377757423286147e-01 with 64 bits of precision)]
In [18]:
[(sqrt(5) - 1)/2, sqrt((sqrt(5) - 1)/2)] # True roots
Out[18]:
2-element Array{Float64,1}:
0.618034
0.786151
In [19]:
# Another example, at which one of the elements of the jacobian matrix blows up, thus blowing up the interval
In [1]:
f(x) = [20 - 20x[1] - x[2], x[1] - x[2]/20 - 1e-9*exp(x[2]/0.052)]
Out[1]:
f (generic function with 1 method)
In [2]:
include("krawczyk2d.jl")
Out[2]:
krawczyk2d (generic function with 1 method)
In [3]:
set_bigfloat_precision(53)
Out[3]:
53
In [4]:
a = [Interval(0.5, 1.2), Interval(0.6, 1.2)]
Out[4]:
2-element Array{Interval,1}:
Interval(5e-01 with 53 bits of precision,1.2000000000000002e+00 with 53 bits of precision)
Interval(5.9999999999999998e-01 with 53 bits of precision,1.2000000000000002e+00 with 53 bits of precision)
In [11]:
jacobian(f, a)
Out[11]:
2x2 Array{Interval,2}:
Interval(-2e+01 with 53 bits of precision,-2e+01 with 53 bits of precision) … Interval(-1e+00 with 53 bits of precision,-1e+00 with 53 bits of precision)
Interval(1e+00 with 53 bits of precision,1e+00 with 53 bits of precision) Interval(-2.0243438806606738e+02 with 53 bits of precision,-5.1972817138715301e-02 with 53 bits of precision)
In [9]:
I = [Interval(1) Interval(0); Interval(0) Interval(1)]
Y(x) = make_intervals(inv(mid(jacobian(f, mid(x)))))
M(x) = I - Y(x)*jacobian(f, x)
K(x) = make_intervals(mid(x)) - Y(x)*make_intervals(f(mid(x))) + M(x)*(x - make_intervals(mid(x)))
Out[9]:
K (generic function with 1 method)
In [12]:
jacobian(f, K(a))
Out[12]:
2x2 Array{Interval,2}:
Interval(-2e+01 with 53 bits of precision,-2e+01 with 53 bits of precision) … Interval(-1e+00 with 53 bits of precision,-1e+00 with 53 bits of precision)
Interval(1e+00 with 53 bits of precision,1e+00 with 53 bits of precision) Interval(-3.1686193971817338e+700 with 53 bits of precision,-4.9999999999999996e-02 with 53 bits of precision)
In [ ]:
krawczyk2d(f, a, 64)
In [ ]:
Content source: kriukov/interval-methods
Similar notebooks: