Question: Error message in a numerical loop

Dear Colleagues,

I think I can certainly take your help. I am trying to run a for-loop; a dummy code is provided below.

for i from 1 to 10 do

Sol_set[i] := solve(f(x, a)=0, x)

end do:

In some iterations at times I get an error message "division by zero". In that case, the program stops abruptly without completing the task for the remaining iterations.

Can I record the solution for any iteration, say j, that gives me an error message as Sol_set[j] := 0 and run the loop for i=j+1 to 10?

Likewise, I need to complete the loop for all iterations with stopping in between. Wherever there is an error, record some arbitrary solution that I can handle offline.

I would appreciate any help in this regard. Thank you all in advance.

Regards,

Omkar

Please Wait...