Algosim documentation: ≈

≈ (almost equal to)

Tests if two objects are equal (with epsilon).

Syntax

Description

If x and y are any two objects, then x ≈ y is true iff x and y are equal, with floating-point values being compared with a default but non-zero epsilon. should be used to compare numeric objects such as numbers, vectors, matrices, and lists containing such elements; not all object types support epsilon comparison.

For numeric objects, x ≈ y differs from x = y because of this epsilon.

Hence, while sin(π) = 0 might be false, sin(π) ≈ 0 will be true.

The operator is implemented by the SameValue function.

Examples

'(0, 1, 2, 3) ≈ '(sin(π), 1, 2, 3)
true

See also