Before going into details, here is a quick version of my question: I have a density plot that has incorrect display (the two red streaks) because data is not being read correctly for two specific keys in a table:
Those two red streaks are incorrect.
I did a bit of debugging and I found what the issue is. My current question, and the reason for this post, is about why the issue is happening. It has to do with accessing values from a table where the keys are of type HFloat.
I will now try to succintly describe the issue, but I have also created a worksheet that reads the matrix with the data for the density plot above, converts the matrix to a table, and then creates the density plot.
These files can be access in a Github repo I created, or as a .zip file attached to this post: table-hfloat.zip
A couple weeks ago, the original question in this entire thread was about how to take an n x 3 matrix and "convert" it to a nested table. Let me recall briefly what this table looks like.
In the outer table, the first column of the matrix are the keys.
This first column can have repeated elements. For each such key, the associated value is a table. This inner table contains as keys the values from the second column of the matrix that have the outer key as the first column in the matrix.
The values associated with each inner key is just the value in the third column of the matrix.
Now, in my other question, I was having trouble with this, but the issue was that the inner keys were floating point numbers. To make the creation of this table work, I converted all keys to HFloat. Then, when accessing keys in the table, I would also type cast to HFloat.
For example, let's say the table is called T and in the matrix there is a row with values 50, 0.95, 3 and another row with values 50, 0.945, 4.
Then we should be able to access T[HFloat(50)][HFloat(0.95)] and get 3, and T[HFloat(50)][HFloat(0.9450)] and get 4.
For the record, each row represents x, y, and z coordinates.
The points represented by the first two columns form a grid.
I created a simple procedure that takes x and y values and returns T[HFloat(x)][HFloat(y)]. I then pass this procedure to plots:-densityplot so that it can get the values it needs.
This works perfectly, except that for some reason there are two inner keys that don't work: 0.945 and 0.9925.
From the density plot pictured above, you can see that the grid is for values of x between 0 and 120, and values of y between 0.90 and 1.11. Every single access of the table works except at values of y of 0.945 and 0.9925, and this is why we get those two red streaks.
I confirmed this by printing out every single attempt at accessing the table.
Why the heck does the access not work for these two values? The linked repo contains all the actual computations in Maple.
One more thing. Weirdly, this works: T[HFloat(50)][HFloat(0.9450000000)]
Ie, I deleted five zeros from the end of the number.
HFloat(0.945000000000000) and HFloat(0.9450000000) seem to produce the same result in Maple.
evalb(HFloat(0.945000000000000) = HFloat(0.9450000000))
results in false, even though if I change the 4 to a 7 then it results in true.