# Further set operations

## Convexification

`ReachabilityAnalysis.convexify`

— Function`convexify(fp::Flowpipe{N, <:AbstractLazyReachSet}) where {N}`

Return a reach-set representing the convex hull array of the flowpipe.

**Input**

`fp`

– flowpipe

**Output**

A reach-set that contains the convex hull array, `ConvexHullArray`

, of the given flowpipe.

**Notes**

The time span of this reach-set is the same as the time-span of the flowpipe.

This function allocates an array to store the sets of the flowpipe.

`convexify(fp::AbstractVector{<:AbstractLazyReachSet{N}}) where {N}`

Return a reach-set representing the convex hull array of the array of the array of reach-sets.

**Input**

`fp`

– array of reach-sets

**Output**

A reach-set that contains the convex hull array, `ConvexHullArray`

, of the given flowpipe.

**Notes**

The time span of this reach-set corresponds to the minimum (resp. maximum) of the time span of each reach-set in `fp`

.

This function allocates an array to store the sets of the flowpipe.

The function doesn't assume that the reach-sets are time ordered.

## Quality measures

`ReachabilityAnalysis.Overapproximate.relative_error`

— Function`relative_error(x, x_ref)`

Compute the relative error between interval `x`

and a reference interval `xref`

.

**Input**

`x`

– interval`xref`

– reference interval

**Output**

An interval representing the relative error (in percentage) of `x`

with respect to the reference interval `xref`

.

**Algorithm**

If $x = [x_L, x_H]$`and`

`xref = [xref_L, xref_H]`

`, the output is the interval`

`y = 100 * [y_L, y_H]`

`computed as`

`y_L = -(x_L - xref_L) / den`

`and`

`y_H = (x_H - xref_H) / den`

`, where`

`den = xref_H - xref_L`

`.

This function measures the relative error between an interval `x`

and a reference interval `x_ref`

accounting for it the lower and the upper range bounds separately (see Eq. (20) in [1]).

**References**

- [1] Althoff, Matthias, Dmitry Grebenyuk, and Niklas Kochdumper. "Implementation of Taylor models in CORA 2018." Proc. of the 5th International Workshop on Applied Verification for Continuous and Hybrid Systems. 2018. pdf