I am working with data that has the following form:
/* initial value */
xi:-8$
/* intermediate value */
a:-0.2$
/* final value */
xf:8$
/* step size */
dx:0.1$
/* first list of values */
x1:makelist(i,i, xi, a, dx)$
/* second list of values */
x2:makelist(i, i, a, xf, dx)$
Then,
is(equal(last(x1), first(x2)));
returns false
.
I suppose the simplest way to avoid this issue would be to define dx = 1/10
, in the given example; however, I was wondering what strategies can be used, if one doesn't have that control over the data?
I considered something like is(equal( floor(last(x1)*10)/10, floor(first(x1)*10)/10 ))
; however, it doesn't seem like that approach would generalize well to cases where one does not know, a priori, the order of magnitude of the quantity.
Is there some version of equal
for floats that checks only to a certain decimal precision? I checked the documentation for both "Functions for Numbers" and "equal" but didn't see anything that would apply (AFAICT).