Resolution of the asin() problem

Let's take the example function


In [1]:
f(x) = asin(x)/x - pi/3


Out[1]:
f (generic function with 1 method)

It has two symmetrical roots, -1/2 and 1/2.

The zero-finding algorithms will encounter the roots as long as we start with the intervals fitting in the domain of arcsin:


In [2]:
using KrawczykMethod


Syntax: krawczyk(function, Interval(lo, hi), precision [default is 64])

In [3]:
krawczyk(f, Interval(-0.9, 0.9))


Unique zero in Interval(-4.99999999999999468768e-01 with 64 bits of precision,-4.99999999999999462507e-01 with 64 bits of precision)
Maybe a zero in Interval(-3.12198595744902126454e-15 with 64 bits of precision,-2.32258541169002204847e-15 with 64 bits of precision)
Maybe a zero in Interval(-2.32258541169002204885e-15 with 64 bits of precision,-1.52318486593102283268e-15 with 64 bits of precision)
Maybe a zero in Interval(-1.52318486593102283287e-15 with 64 bits of precision,-7.23784320172023617034e-16 with 64 bits of precision)
Maybe a zero in Interval(-7.23784320172023617226e-16 with 64 bits of precision,7.56162255869755988157e-17 with 64 bits of precision)
Maybe a zero in Interval(7.56162255869755988037e-17 with 64 bits of precision,8.75016771345974814737e-16 with 64 bits of precision)
Maybe a zero in Interval(8.75016771345974814689e-16 with 64 bits of precision,1.67441731710497403067e-15 with 64 bits of precision)
Maybe a zero in Interval(1.67441731710497403048e-15 with 64 bits of precision,2.47381786286397324665e-15 with 64 bits of precision)
Maybe a zero in Interval(2.47381786286397324646e-15 with 64 bits of precision,3.27321840862297246234e-15 with 64 bits of precision)
Unique zero in Interval(4.99999999999999461721e-01 with 64 bits of precision,4.99999999999999468741e-01 with 64 bits of precision)
Out[3]:
10-element Array{Any,1}:
 {Interval(-4.99999999999999468768e-01 with 64 bits of precision,-4.99999999999999462507e-01 with 64 bits of precision),:unique}  
 {Interval(-3.12198595744902126454e-15 with 64 bits of precision,-2.32258541169002204847e-15 with 64 bits of precision),:possible}
 {Interval(-2.32258541169002204885e-15 with 64 bits of precision,-1.52318486593102283268e-15 with 64 bits of precision),:possible}
 {Interval(-1.52318486593102283287e-15 with 64 bits of precision,-7.23784320172023617034e-16 with 64 bits of precision),:possible}
 {Interval(-7.23784320172023617226e-16 with 64 bits of precision,7.56162255869755988157e-17 with 64 bits of precision),:possible} 
 {Interval(7.56162255869755988037e-17 with 64 bits of precision,8.75016771345974814737e-16 with 64 bits of precision),:possible}  
 {Interval(8.75016771345974814689e-16 with 64 bits of precision,1.67441731710497403067e-15 with 64 bits of precision),:possible}  
 {Interval(1.67441731710497403048e-15 with 64 bits of precision,2.47381786286397324665e-15 with 64 bits of precision),:possible}  
 {Interval(2.47381786286397324646e-15 with 64 bits of precision,3.27321840862297246234e-15 with 64 bits of precision),:possible}  
 {Interval(4.99999999999999461721e-01 with 64 bits of precision,4.99999999999999468741e-01 with 64 bits of precision),:unique}    

In [4]:
using NewtonMethod


Syntax: newton(function, Interval(lo, hi), precision [default is 64])

In [5]:
newton(f, Interval(-0.9, 0.9))


Function calls: 13
Out[5]:
2-element Array{Interval,1}:
 Interval(-4.99999999999999321696e-01 with 64 bits of precision,-4.99999999999999319094e-01 with 64 bits of precision)
 Interval(4.99999999999999319094e-01 with 64 bits of precision,4.99999999999999321181e-01 with 64 bits of precision)  

But if we set the interval which goes outside of the domain, we get errors.


In [6]:
krawczyk(f, Interval(-2, 2))


DomainError
while loading In[6], in expression starting on line 1

 in asin at mpfr.jl:573
 in asin at /home/kriukov/main/work/mexico/unam/interval-methods/modules/IntervalArithmetic.jl:507
 in f at In[1]:1
 in differentiate at /home/kriukov/main/work/mexico/unam/interval-methods/modules/AutoDiff.jl:101
 in krawczyk_internal at /home/kriukov/main/work/mexico/unam/interval-methods/modules/KrawczykMethod.jl:37
 in krawczyk at /home/kriukov/main/work/mexico/unam/interval-methods/modules/KrawczykMethod.jl:64
 in krawczyk at /home/kriukov/main/work/mexico/unam/interval-methods/modules/KrawczykMethod.jl:25

In [7]:
newton(f, Interval(-2, 2))


DomainError
while loading In[7], in expression starting on line 1

 in asin at mpfr.jl:573
 in asin at /home/kriukov/main/work/mexico/unam/interval-methods/modules/IntervalArithmetic.jl:507
 in f at In[1]:1
 in differentiate at /home/kriukov/main/work/mexico/unam/interval-methods/modules/AutoDiff.jl:101
 in N at /home/kriukov/main/work/mexico/unam/interval-methods/modules/NewtonMethod.jl:16
 in newton at /home/kriukov/main/work/mexico/unam/interval-methods/modules/NewtonMethod.jl:33
 in newton at /home/kriukov/main/work/mexico/unam/interval-methods/modules/NewtonMethod.jl:13

In [ ]: