# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `~=`, `_approx`

Approximate equality

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```x ~= y
_approx(`x`, `y`)
```

## Description

`x ~= y` symbolizes approximate equality.

`x ~= y` is equivalent to the function call ```_approx(x, y)```.

The operator `~=` returns a symbolic expression representing an approximate equality for numerical values `x` and `y`. The calls `bool(x ~= y)` and `is(x ~= y)` check whether `|float((x - y)/x)| < 10^(-DIGITS)` is satisfied, provided `x ≠ 0` and ```y ≠ 0```. Thus, `TRUE` is returned if `x` and `y` coincide within the relative numerical precision specified by `DIGITS`. For `x = 0`, the criterion is ```|float(y)| < 10^(-DIGITS)```. For `y = 0`, the criterion is `|float(x)| < 10^(-DIGITS)`. If either `x` or `y` contains a symbolic object that cannot be converted to a real or complex floating-point number, the functions `bool` and `is` return the value `UNKNOWN`.

Approximate equalities have two operands: the left side and the right side. Use `lhs` and `rhs` to extract these operands.

### Note

`a ~= b` is not equivalent to ```a - b ~= 0```.

## Examples

### Example 1

In the following example, note the difference between syntactical and numerical equality. The numbers 1.5 and coincide numerically. However, 1.5 is of domain type `DOM_FLOAT`, whereas is of domain type `DOM_RAT`. Consequently, they are not regarded as equal in the following syntactical test:

`1.5 = 3/2; bool(%)`

For equations with floating-point numbers, use the operator `~=` instead of `=`. The functions `bool` and `is` test whether the floating-point approximations coincide up to the relative precision given by `DIGITS`:

```1.5 ~= 3/2; bool(1.5 ~= 3/2); is(1.5 ~= 3/2);```

## Parameters

 `x`, `y` Arbitrary MuPAD® objects

## Return Values

Expression of type `"_approx"`.