"Blackboard 3" Calculator

Graphical display of results

By running the example with the game given at the end of the previous paragraph, you can only find out who won. To follow the twists and turns of the game, you need to use the export(name) keyword. In fact, this is a function that, in the process of counting, collects all the values of the expression specified by its argument. After the end of the count, the collected data is automatically displayed in the form of a graph.

The following formulas differ from those considered in the previous paragraph by the presence of two export() functions, one for each of the players:

Sam =0
John = 0
    Sam = Sam + random(1)
    John = John + random(1)
until(Sam = 10 Or John = 10)

The result is this:

The horizontal axis is always the number of the cycle, and the vertical axis is the value of the variable in this cycle. In this case, it is the number of wins of this or that player. It can be seen that the struggle was intense - first one player, then the other came forward.

The best way to figure out how you can manipulate the graphs is to run formulas in the Blackboard calculator.

When you hover the mouse over the nodal points of the chart, a tooltip appears with the coordinates of this point, that is, the cycle number and the value of the variable. The menu in the upper right corner of the Chart Canvas allows you to print charts or save them as a jpeg or png image.

Clicking on the legend item located at the bottom of the canvas hides / shows the corresponding color graph. Moreover, after the removal of the highest (lowest) graph, all others are rebuilt so as to occupy the entire height of the canvas.

The accuracy of the values displayed on the graphs is the same as that of the numbers displayed in the calculator window (that is, it is determined by the number in the "Signs after 0" field).

Tip. If the graphs are stepped, then, most likely, there are not enough fractional decimal places specified

Graphs built on a large number of points can be scaled and then moved with the mouse. This means that an area selected with the mouse that is narrower than the canvas is automatically stretched to the full width of the canvas. The resulting window can be moved along the horizontal axis in order to view the graphs in detail in neighboring areas. The scaling operation can be repeated several times until all the details of the graphs behavior are visible.

This process is controlled by only two buttons that appear in the upper right corner of the canvas when an area is selected. The left button allows you to move the window, and the right button removes the scaling and restores the original view of the chart.

To demonstrate the usefulness of scaling, consider formulas that tabulate the function y = sin[1/(|x-0.5| + 0.000001)] on the interval [0, 1].

x = 0
h = 0.00001
    y = sin[1/(|x-0.5|+0.000001)]
    x = x+h export(y)

We get the following graph:

How the graph behaves in the middle, that is, in the vicinity of the point x = 0.5, (the number of cycles is 50,000) is absolutely not clear. Let's select the interval from x = 0.49 to x = 0.51:

Again, nothing is visible. And, finally, from the fourth time in the range from x = 0.4996. up to x = 0.5004 we get the required:

For example, now we can say that there is a local maximum at the point x = 0.5, at which the function takes on the value y = -0.66.

Export() functions can in principle be located anywhere. But you need to understand that the values they save depend on their location, namely: the current value of the argument is captured at the time of execution of this function. Therefore, it is recommended to place export() functions only in loops and, preferably, at the end of the loop body.

If there are several loops, sequential or nested within each other, then the export() function of the same argument is best placed in all of these loops to collect all the information about the change in the observed value.

The same applies to blocks of branching constructs like if...endif, which will be discussed in the next section.

Finally, any mathematical expression can be used as an argument to export(). For example, you can switch to a logarithmic scale by replacing export(y) with export(ln(y)).