# Dynamic Mode Decomposition with control

Dynamic Mode Decomposition with Control is a method for generating an approximating linear differential equation in a chosen basis of observables. If `X`

and `Y`

are data matrices containing points of the same trajectory and `U`

containing the exogenous inputs acting on that trajectory, then `DMDc`

approximates

where $\dagger$ denotes the Moore-Penrose pseudoinverse and `K`

is the approximation of the Koopman Operator and `B`

the linear input map.

`DMDc`

approximates *discrete time systems* with inputs $z$ of the form

`gDMDc`

approximates *continuous time systems* with inputs $z$ of the form

where $K_{G}$ is the generator of the Koopman Operator.

## Functions

`DataDrivenDiffEq.DMDc`

— Function```
DMDc(X, U; B, alg)
DMDc(X, Y, U; B, alg)
```

Approximates a 'LinearKoopman' with the `AbstractKoopmanAlgorithm`

'alg' from the data matrices `X`

and `U`

or `X`

, `U`

and `Y`

respectively. If only `X`

is given, the data is split into `X[:, 1:end-1]`

and `X[:, 2:end]`

. `B`

represents the matrix mapping the input onto `Y`

, which may be known a priori.

**Example**

```
alg = DMDPINV()
koopman = DMDc(X, U, alg = alg)
koopman = DMD(X[:, 1:end-1], X[:, 2:end], U, alg = alg)
```

`DataDrivenDiffEq.gDMDc`

— Function```
gDMDc(X, Y, U; B, alg)
gDMDc(t, X, U; B, dt, alg, fdm, itp)
```

Approximates a 'LinearKoopman' with the `AbstractKoopmanAlgorithm`

'alg' from the data matrices `X`

and `U`

or `X`

, `U`

and `Y`

, respectively. `X`

should contain the state trajectory and `Y`

the differential state trajectory.`B`

represents the matrix mapping the input onto `Y`

, which may be known a priori.

If no measurements of the differential state are available, `gDMDc`

can be called with measurement time points `t`

as the first argument. It will then create an interpolation using the interpolation method from `DataInterpolations.jl`

defined in `itp`

. The trajectory will then be resampled to equidistant measurements over time corresponding to the mean of `diff(t)`

or `dt`

, if given. The differential state measurements will be computed via 'FiniteDifferences.jl', given a `FiniteDifferenceMethod`

in `fdm`

.

**Example**

```
koopman = gDMDc(X, Y, U)
fdm = backward_fdm(5,1)
itp = CubicSpline
koopman = gDMD(t, X, U, fdm = fdm, itp = itp)
```