Representing Several IF statements inside a FOR loop in Math Notation

908 Views Asked by At

I wish to correctly represent several IF statements within a for loop in math notation.

The FOR loop can be represented as:

∀i∈ {0,…,n-1} . (Conditional IF statements)

The IF statements apply to 3 thresholds Tblue, Tred and Tmax, of some predefined value, where Tblue < Tred < TMax.

red and blue are two integers local to the FOR loop.

The Input Array [In] is an array of integers to be assessed, the Output Array [Out] is an empty array of a two-integer structure to store the results of the assessment.

The IF statements are represented as pseudocode below:

if In[i] < Tblue 
   Then red = blue = 0;

else if (In[i] >= Tblue AND In[i] < Tred)
    Then blue = In[i], red = 0;

else if (In[i] >= TRed AND In[i] < Tmax)
    Then red = In[i], blue = 0;

else if (In[i] >= TMax)
    Then red = TRed, blue = 0;

Out[i] = {blue,red};
1

There are 1 best solutions below

0
On BEST ANSWER

I found an answer from a different source:

enter image description here