8 years, 20 days

## Error message in a numerical loop...

Maple

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

## Roots, lists and substitute...

Maple

Dear Friends,

I would appreciate your help in resolving some issues. Let me describe my dummy code and the issues I am having.

1. I have two functions f(x,a) and g(x,a) are well defined.

2. I need to get roots of f(x,a). I am using the command soln := Roots(f(x,a)) which gives me a list of all possible values of x.

3. I need to choose only one element -- say x* -- from the list "soln" such that x*=argmax{g(x,a) | g(x,a)>0 for x in soln}.

I am not able to find a technique (i) to evaluate g(x,a) for all elements of the list "soln", (ii) and select x* that maximizes g(x,a).

Picking and choosing elements of the list one by one is difficult since the number of elements in the list can vary with parameter "a" and it would complicate the matter in numerical studies.

I would sincerely appreciate any inputs in this regard.

Thank you,

Omkar

## How do I filter a set?...

Maple 13

Dear Colleagues,

I am not sure if there exist a simple way to handle the issues I am facing. I am trying to obtain numeric roots for a polynomial f(x,a). I know for sure that there can be many roots depending on the value of parameter a. However, I cannot say for sure how many roots are possible for each value of parameter a. Some of these roots are complex numbers. Also, I need to choose only those roots that have following properties:

1. They are real.

2. f(x*,a) i.e., function value at a root is positive.

How do I solve f(x,a)=0 to store all roots in a set? Furthermore, how do I select and print roots that have the properties mentioned above? Is there a way to do filtering of a set specifying properties of the members of the set? Please suggest. Your help is highly appreciated.

Regards,

Omkar

 1 2 3 Page 3 of 3
﻿