Question: iterated try-catch code

What i am trying to achieve is to evaluate the sequence as, shown, but from within a try-catch statement that handles and keeps a tally on the number and arguements for which the sequence encounters a division by zero error. ie, instead of haulting evaluation when each error is encountered, i want my code to record the index values at which the error occured, then continue on to the next term.
 

restart

with(Statistics):

``

F := (-2*n[1]*n[3]-4*n[2]*n[1]*n[3]+4*n[2]*n[3]+4*n[3]*n[4]*n[1]+n[1])/(-n[1]-2*n[2]*n[1]+2*n[2]+2*n[4]*n[1]):

S := proc (N, M, G, L) options operator, arrow; [seq(seq(seq(seq(F, n[1] = N .. N), n[2] = M .. M), n[3] = G .. G), n[4] = L .. L)] end proc

proc (N, M, G, L) options operator, arrow; [seq(seq(seq(seq(F, n[1] = N .. N), n[2] = M .. M), n[3] = G .. G), n[4] = L .. L)] end proc

(1)

A := {}; -1; U := 0; -1; K := 0; -1; E := 0

0

(2)

J := 0:

H := 1

1

(3)

K[1] := J+H:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

[-1]

(4)

J := 0:

H := 1

1

(5)

K[1] := J:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

[0]

(6)

J := 0:

H := 1

1

(7)

K[1] := J:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

1

 

{[0, 0, 1, 0]}

(8)

J := 0:

H := 1

1

(9)

K[1] := J:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

2

 

{[0, 0, 0, 1]}

(10)

``


 

Download PLEASE_HELP_MAPLE.mw

Please Wait...