Documentation

# `solvelib`::`preImage`

Preimage of a set under a mapping

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

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

## Syntax

```solvelib::preImage(`a`, `x`, `S`)
```

## Description

`solvelib::preImage(a, x, S)` returns the set of all numbers `y` such that substituting `y` for `x` in `a` gives an element of `S`.

`S` can be a set of any type (finite or infinite).

## Examples

### Example 1

In case of a finite set `S`, the preimage of S is just the union of all sets `solve(a=s, x)`, where `s` ranges over the elements of `S`.

`solvelib::preImage(x^2+2, x, {11, 15});`
` `

Note that computing this set may take a long time for large finite sets:

```time(solvelib::preImage(x, x, Z_ intersect Dom::Interval(0, 1000000)))```
` `

### Example 2

For intervals, the preimage is usually an interval or a union of intervals.

`solvelib::preImage(x^2+2, x, Dom::Interval(3..7));`
` `

## Parameters

 `a` Arithmetic expression `x` Identifier `S` Set

Set