algebrite
Version:
Computer Algebra System in Coffeescript
217 lines (143 loc) • 2.41 kB
text/coffeescript
test_power = ->
run_test [
"2^(1/2)",
"2^(1/2)",
"2^(3/2)",
"2*2^(1/2)",
"(-2)^(1/2)",
"i*2^(1/2)",
"3^(4/3)",
"3*3^(1/3)",
"3^(-4/3)",
"1/(3*3^(1/3))",
"3^(5/3)",
"3*3^(2/3)",
"3^(2/3)-9^(1/3)",
"0",
"3^(10/3)",
"27*3^(1/3)",
"3^(-10/3)",
"1/(27*3^(1/3))",
"(1/3)^(10/3)",
"1/(27*3^(1/3))",
"(1/3)^(-10/3)",
"27*3^(1/3)",
"27^(2/3)",
"9",
"27^(-2/3)",
"1/9",
"102^(1/2)",
"2^(1/2)*3^(1/2)*17^(1/2)",
"32^(1/3)",
"2*2^(2/3)",
"9999^(1/2)",
"3*11^(1/2)*101^(1/2)",
"10000^(1/3)",
"10*2^(1/3)*5^(1/3)",
"sqrt(1000000)",
"1000",
"sqrt(-1000000)",
"1000*i",
"sqrt(2^60)",
"1073741824",
# this is why we factor irrationals
"6^(1/3) 3^(2/3)",
"3*2^(1/3)",
# inverse of complex numbers
"1/(2+3*i)",
"2/13-3/13*i",
"1/(2+3*i)^2",
"-5/169-12/169*i",
"(-1+3i)/(2-i)",
"-1+i",
# other
"(0.0)^(0.0)",
"1",
"(-4.0)^(1.5)",
"-8*i",
"(-4.0)^(0.5)",
"2*i",
"(-4.0)^(-0.5)",
"-0.5*i",
"(-4.0)^(-1.5)",
"0.125*i",
# more complex number cases
"(1+i)^2",
"2*i",
"(1+i)^(-2)",
"-1/2*i",
"(1+i)^(1/2)",
"(-1)^(1/8)*2^(1/4)",
"(1+i)^(-1/2)",
"-(-1)^(7/8)/(2^(1/4))",
"(1+i)^(0.5)",
"1.09868+0.45509*i",
"(1+i)^(-0.5)",
"0.776887-0.321797*i",
# test cases for simplification of polar forms, counterclockwise
"exp(i*pi/2)",
"i",
"exp(i*pi)",
"-1",
"exp(i*3*pi/2)",
"-i",
"exp(i*2*pi)",
"1",
"exp(i*5*pi/2)",
"i",
"exp(i*3*pi)",
"-1",
"exp(i*7*pi/2)",
"-i",
"exp(i*4*pi)",
"1",
"exp(A+i*pi/2)",
"i*exp(A)",
"exp(A+i*pi)",
"-exp(A)",
"exp(A+i*3*pi/2)",
"-i*exp(A)",
"exp(A+i*2*pi)",
"exp(A)",
"exp(A+i*5*pi/2)",
"i*exp(A)",
"exp(A+i*3*pi)",
"-exp(A)",
"exp(A+i*7*pi/2)",
"-i*exp(A)",
"exp(A+i*4*pi)",
"exp(A)",
# test cases for simplification of polar forms, clockwise
"exp(-i*pi/2)",
"-i",
"exp(-i*pi)",
"-1",
"exp(-i*3*pi/2)",
"i",
"exp(-i*2*pi)",
"1",
"exp(-i*5*pi/2)",
"-i",
"exp(-i*3*pi)",
"-1",
"exp(-i*7*pi/2)",
"i",
"exp(-i*4*pi)",
"1",
"exp(A-i*pi/2)",
"-i*exp(A)",
"exp(A-i*pi)",
"-exp(A)",
"exp(A-i*3*pi/2)",
"i*exp(A)",
"exp(A-i*2*pi)",
"exp(A)",
"exp(A-i*5*pi/2)",
"-i*exp(A)",
"exp(A-i*3*pi)",
"-exp(A)",
"exp(A-i*7*pi/2)",
"i*exp(A)",
"exp(A-i*4*pi)",
"exp(A)",
]