I just checked with directional derivative, which is probably cleaner.  It is a
little tricky to adjust the distance between points:  if it's too small, the
derivative makes no difference and bugs in bug testing code were (!) not
detected.  (originally I subtracted a bogus correction).  If it's too large,
the epsilonAbsolute is violated.

In any case, I should provide a testNumeric function in the Unittest package,
that outputs the size of the error if it's too large, I think.

)expose UnittestCount UnittestAux Unittest

epsilonAbsolute := 1.0e-15
epsilonrelative := 1.0e-30

testComplexFloat(a: String, b: String): Void ==
    testTrue("norm(" a "-" b") < epsilonAbsolute")
    testTrue("norm(" a "/" b "-1) < epsilonRelative")

testsuite "branch cuts"
testcaseNoClear "asin"
DirD := eval(D(asin(x0+(x1-x0)*t), t)::EXPR FLOAT, t=0)

tmax := 10
tdiff := 1.0e-8

-- t =  0..tmax
-- x = -2..2
X t == -2.0 + t/tmax * 4.0
y x == sqrt(-x^2 + 4.0)/2.0

-- t = 0: arg1 is on the negative x-axis, arg2 in quadrant II 
for t in 0..tmax-1 repeat
    output(4*t+1)
    arg1 := (X t + %i * y X t)::Complex Float
    arg2 := (X(t+tdiff) + %i * y X(t+tdiff))::Complex Float
    corr := (eval(DirD, [x0=arg1, x1=arg2]))::Complex Float
    output(norm(asin arg1 + corr - asin arg2))
    output(norm(asin(arg1::Complex DFLOAT) + corr - asin(arg2::Complex
DFLOAT)))
    testComplexFloat("asin arg1 + corr", "asin arg2")
    testComplexFloat("asin(arg1::Complex DFLOAT) + corr", 
                     "asin(arg2::Complex DFLOAT)")

X t == 2.0 - t/tmax * 4.0
y x == -sqrt(-x^2 + 4.0)/2.0
-- t = tmax: arg1 is on the positive x-axis, arg2 in quadrant IV
for t in 0..tmax-1 repeat
    output(4*(t+tmax)+1)
    arg1 := (X t + %i * y X t)::Complex Float
    arg2 := (X(t+tdiff) + %i * y X(t+tdiff))::Complex Float
    corr := (eval(DirD, [x0=arg1, x1=arg2]))::Complex Float
    output(norm(asin arg1 + corr - asin arg2))
    output(norm(asin(arg1::Complex DFLOAT) + corr - asin(arg2::Complex
DFLOAT)))
    testComplexFloat("asin arg1 + corr", "asin arg2")
    testComplexFloat("asin(arg1::Complex DFLOAT) + corr", 
                     "asin(arg2::Complex DFLOAT)")


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to fricas-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to