"Testing bug fixes"

clear

-- numerator and denominator had an infinite loop

T = numerator(-(-i + i * exp(2 * i * x)) / (exp(2 * i * x) + 1))
check(T = i - i * exp(2 * i * x))
T = denominator(-(-i + i * exp(2 * i * x)) / (exp(2 * i * x) + 1))
check(T = exp(2 * i * x) + 1)

-- this was broken, returned a complex number

T = arccos(0.4529)
check(infixform(T)="1.10078")

-- this was broken, now fixed

z = sqrt(i)
T = z conj(z)
check(T == 1)

z = (-1)^a
T = z conj(z)
check(T == 1)

-- verify that defint works in a denominator

I(y) = defint((1 + cos(theta)^2) sin(theta),theta,0,y)
T = I(theta) / I(pi)
check(T = -1/8 cos(theta)^3 - 3/8 cos(theta) + 1/2)

-- log of number is factored

check(log(1/10) = -log(2) - log(5))

clear
check(i exp(1/4 i pi) exp(1/4 i pi) == -1)
check(i exp(1/8 i pi) == exp(5/8 i pi))
check(infixform(cos(1/3.0 pi)) == "0.5")
check(infixform(sin(1/6.0 pi)) == "0.5")
check(infixform(polar(2.0 + 3.0 i)) == "3.60555 exp(0.312833 i pi)")
check(infixform(exp(0.5 i pi)) == "i") -- was 1.0 i
check(infixform(arg(1.0 i)) == "1.5708") -- was 1/2 pi
check(infixform(log(1.0 i)) == "1.5708 i") -- was 1/2 i pi
check(infixform(1/abs(2.0+3.0i)) == "0.27735")
check(infixform(1/arg(2.0+3.0i)) == "1.01751")
check(infixform(1/mag(2.0+3.0i)) == "0.27735")
check((1/3)^x == 3^(-x))
check(i^x == (-1)^(x/2))
check((-2/3)^x == 2^x 3^(-x) (-1)^x)
check(infixform((-2/3)^1.2) == "-0.497334 - 0.361334 i")
check((-192)^x == 2^(6 x) 3^x (-1)^x)
check((3,4,5) - 2 == (1,2,3))
check(infixform(A + B - B + 0) == "A")
check(infixform(0.0) == "0")
check(sqrt(-i) == sqrt(-1) sqrt(i))
check(prefixform((-2 i pi hbar epsilon / m)^(3/2)) ==
"(* 2 (^ 2 1/2) (^ -1 1/4) (^ epsilon 3/2) (^ hbar 3/2) (^ m -3/2) (^ pi 3/2))")
check(prefixform(hbar Rbc) == "(* Rbc hbar)") -- fails for Javascript localeCompare
check(infixform(-0) == "0") -- eigenmath.js result was -0, now fixed

check(infixform(abs(32/59049)) == "32/59049") -- bug in absfunc(), now fixed
check(infixform(abs(-32/59049)) == "32/59049")

-- fixed in version 3.24

eta = 1 / ((18.7179 (0.399323 - 0.91681 i) - 6.61777 i (0.399323 - 0.91681 i)) (18.7179 (0.399323 + 0.91681 i) + 6.61777 i (0.399323 + 0.91681 i)))

check(infixform(rect(eta)) == "0.00253708")
check(infixform(polar(eta)) == "0.00253708")
check(infixform(simplify(eta)) == "0.00253708")

-- log(0.0) caused stop, fixed in version 3.26
check(log(0.0) == log(0))

psi = (1,1) / sqrt(2)
sigmay = ((0,-i),(i,0))
check(rotate(psi,Y,0) == dot(sigmay,psi))
