# 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.

# and

Logical AND for symbolic expressions

## Syntax

```A & B and(A,B) ```

## Description

`A & B` represents the logical conjunction. `A & B` is true only when both `A` and `B` are true.

`and(A,B)` is equivalent to `A & B`.

## Input Arguments

 `A` Symbolic equation, inequality, or logical expression that contains symbolic subexpressions. `B` Symbolic equation, inequality, or logical expression that contains symbolic subexpressions.

## Examples

Combine these symbolic inequalities into the logical expression using `&`:

```syms x y xy = x >= 0 & y >= 0;```

Set the corresponding assumptions on variables `x` and `y` using `assume`:

`assume(xy)`

Verify that the assumptions are set:

`assumptions`
```ans = [ 0 <= x, 0 <= y]```

Combine two symbolic inequalities into the logical expression using `&`:

```syms x range = 0 < x & x < 1;```

Replace variable `x` with these numeric values. If you replace `x` with 1/2, then both inequalities are valid. If you replace `x` with 10, both inequalities are invalid. Note that `subs` does not evaluate these inequalities to logical `1` or `0`.

```x1 = subs(range, x, 1/2) x2 = subs(range, x, 10)```
```x1 = 0 < 1/2 & 1/2 < 1 x2 = 0 < 10 & 10 < 1```

To evaluate these inequalities to logical `1` or `0`, use `isAlways`:

```isAlways(x1) isAlways(x2)```
```ans = logical 1 ans = logical 0```

Note that `simplify` does not simplify these logical expressions to logical `1` or `0`. Instead, they return symbolic values `TRUE` or `FALSE`.

```s1 = simplify(x1) s2 = simplify(x2)```
```s1 = TRUE s2 = FALSE```

Convert symbolic `TRUE` or `FALSE` to logical values using `isAlways`:

```isAlways(s1) isAlways(s2)```
```ans = logical 1 ans = logical 0```

The recommended approach to define a range of values is using `&`. Nevertheless, you can define a range of values of a variable as follows:

```syms x range = 0 < x < 1;```

Now if you want to replace variable `x` with numeric values, use symbolic numbers instead of MATLAB® double-precision numbers. To create a symbolic number, use `sym`

```x1 = subs(range, x, sym(1/2)) x2 = subs(range, x, sym(10))```
```x1 = (0 < 1/2) < 1 x2 = (0 < 10) < 1```

Evaluate these inequalities to logical `1` or `0` using `isAlways`.

```isAlways(x1) isAlways(x2)```
```ans = logical 1 ans = logical 0```