Question: Testing for a complex number

I need to test a list of numbers to find if any of them are complex. if a complex is found then remove that complete row from the list. the potential complex numbers in my list are a, b and c. b is complex i.e has a non zero imaginery part in row 1 so only row 1 should get deleted. the a b and c were originally generated from the arcsin function. Would appreciate help on this. I know it should be simple enough to do. Thanks in advance.

``

X := [-311.33373, -0.3e-4]

[-311.33373, -0.3e-4]

(1)

Y := [250.56151, -0.495e-1]

[250.56151, -0.495e-1]

(2)

Z := [93.29802, 668.8913]

[93.29802, 668.8913]

(3)

a := [28.60830, 0.2e-4]

[28.60830, 0.2e-4]

(4)

b := [90.00000-3.77234*I, 0.1e-4]

[90.00000-3.77234*I, 0.1e-4]

(5)

c := [-24.94060, -54.20180]

[-24.94060, -54.20180]

(6)

for i to nops(X) do if `or`(`or`(Im(a[i]) <> 0, Im*b[i] <> 0), Im(c[i]) <> 0) then X[i] := xx; Y[i] := xx; Z[i] := xx; a[i] := xx; b[i] := xx; c[i] := xx end if end do

X

[xx, xx]

(7)

Y

[xx, xx]

(8)

Z

[xx, xx]

(9)

a

[xx, xx]

(10)

b

[xx, xx]

(11)

c

[xx, xx]

(12)

select(has, X, xx); 1; X := remove(has, X, xx)

[]

(13)

select(has, Y, xx); 1; Y := remove(has, Y, xx)

[]

(14)

select(has, Z, xx); 1; Z := remove(has, Z, xx)

[]

(15)

select(has, a, xx); 1; a := remove(has, a, xx)

[]

(16)

select(has, b, xx); 1; b := remove(has, b, xx)

[]

(17)

select(has, c, xx); 1; c := remove(has, c, xx)

[]

(18)

``


Download complex_test.mw

Please Wait...