# Functions for finding reductions

### Finding reductions

`ExactODEReduction.find_reductions`

— Function`find_reductions(system::ODE; overQ=true, makepositive=false, loglevel=Logging.Info)`

Finds reductions of the system corresponding to a Jordan-Hoelder filtration. This means that the reduction form a chain, and there are no extra intermediate reduction in this chain. In particular, if there exists at least one reduction, it will be found.

Arguments:

`system`

is an ODE system given as`ODE`

object,`overQ`

tells the algorithm to search for reductions over rational numbers. Is`true`

by default,`seed`

is a seed for the random number generator,`makepositive`

tells the algorithm to search for reductions with positive coefficients.`false`

by default.

To enable this argument, you should have `Polymake.jl`

imported.

`loglevel`

is a level of logging.`Logging.Info`

by default.`parameter_strategy`

prescribes the way the parameter in the resulting system will be recognized:`:inheritance`

(default) the parameters in the new system are exactly combinations of the original parameters`:constants`

the parameters in the new system will be the variables with zero dynamics`:none`

- no parameters in the result

Example:

```
julia> using ExactODEReduction
julia> odes = @ODEsystem(
x'(t) = x + y,
y'(t) = x - y - z,
z'(t) = 2x - z
)
julia> find_reductions(odes)
A chain of 2 reductions of dimensions 1, 2.
==================================
1. Reduction of dimension 1.
New system:
y1'(t) = 0
New variables:
y1 = x + y - z
==================================
2. Reduction of dimension 2.
New system:
y1'(t) = -y1(t) + y2(t)
y2'(t) = y1(t) - y2(t)
New variables:
y1 = x - z
y2 = y
```

`ExactODEReduction.find_smallest_constrained_reduction`

— Function`find_smallest_constrained_reduction(system::ODE, observables; overQ=true, makepositive=false, loglevel=Logging.Info)`

Finds the best linear reduction of the system. If there exists a reduction, it will be found.

Arguments:

`system`

is an ODE system given as`ODE`

object,`observables`

is a list of linear functions of initial variables desired to be preserved by reduction,`overQ`

tells the algorithm to search for reductions over rational numbers. Is`true`

by default,`seed`

is a seed for the random number generator,`makepositive`

tells the algorithm to search for reductions with positive coefficients.`false`

by default.

To enable this argument, you should have `Polymake.jl`

imported.

`loglevel`

is a level of logging.`Logging.Info`

by default.`parameter_strategy`

prescribes the way the parameter in the resulting system will be recognized:`:inheritance`

(default) the parameters in the new system are exactly combinations of the original parameters`:constants`

the parameters in the new system will be the variables with zero dynamics`:none`

- no parameters in the result

Example:

```
julia> using ExactODEReduction
julia> odes = @ODEsystem(
x'(t) = x + y,
y'(t) = x - y - z,
z'(t) = 2x - z
)
julia> find_smallest_constrained_reduction(odes, [x + (1//2)*z])
Reduction of dimension 2.
New system:
y1'(t) = 2*y1(t) + y2(t)
y2'(t) = -2*y1(t) - y2(t)
New variables:
y1 = x + 1//2*z
y2 = y - 3//2*z
```

`ExactODEReduction.find_some_reduction`

— Function`find_some_reduction(system::ODE; overQ, seed, makepositive, loglevel, parameter_strategy)`

Finds a nontrivial linear reduction of the system. If there exists a reduction, it will be found.

Arguments:

`system`

is an ODE system given as`ODE`

object,`overQ`

tells the algorithm to search for reductions over rational numbers. Is`true`

by default,`seed`

is a seed for the random number generator,`makepositive`

tells the algorithm to search for reductions with positive coefficients.`false`

by default.

To enable this argument, you should have `Polymake.jl`

imported.

`loglevel`

is a level of logging.`Logging.Info`

by default.`parameter_strategy`

prescribes the way the parameter in the resulting system will be recognized:`:inheritance`

(default) the parameters in the new system are exactly combinations of the original parameters`:constants`

the parameters in the new system will be the variables with zero dynamics`:none`

- no parameters in the result

Example:

```
julia> using ExactODEReduction
julia> odes = @ODEsystem(
x'(t) = x + y,
y'(t) = x - y - z,
z'(t) = 2x - z
)
julia> find_some_reduction(odes)
Reduction of dimension 1.
New system:
y1'(t) = -2*y1(t)
New variables:
y1 = x - y - z
```

### Exploring found reductions

The functions `find_some_reduction`

and `find_smallest_constrained_reduction`

return a `Reduction`

object.

`ExactODEReduction.Reduction`

— Type`Reduction`

Represents a single reduction of some ODE system. This is returned from reduction functions.

Example:

```
using ExactODEReduction
odes = @ODEsystem(
x'(t) = x + y,
y'(t) = x - y - z,
z'(t) = 2x - z
)
reduction = find_some_reduction(odes)
## prints
Reduction of dimension 1.
New system:
y1'(t) = y1(t)
New variables:
y1 = x + 1//2*y - 1//4*z
new_system(reduction)
## prints
y1'(t) = y1(t)
new_vars(reduction)
## prints
Dict{Nemo.fmpq_mpoly, Nemo.fmpq_mpoly} with 1 entry:
y1 => x + 1//2*y - 1//4*z
```

`ExactODEReduction.new_system`

— Function`new_system(r::Reduction)`

Returns the `ODE`

object that defines the reduced system.

`ExactODEReduction.new_vars`

— Function`new_system(r::Reduction)`

Returns the dictionary of new macro-variables expressed as linear combinations of the original variables.

`ExactODEReduction.old_system`

— Function`old_system(r::Reduction)`

Returns the `ODE`

object that defines the original system.

`ExactODEReduction.new_initialconds`

— Function`new_initialconds(r::Reduction, ics::Dict)`

Returns a dictionary of initial conditions for the new variables as defined by the given reduction.

`ExactODEReduction.reduce_data`

— Function`reduce_data(data::Array{Any, 2}, r::Reduction)`

For a time-series data for the original system, returns the corresponding time series for the reduction

The function `find_reduction`

returns a `ChainOfReductions`

object, which, in practice, can be treated as `Vector{Reduction}`

.

`ExactODEReduction.ChainOfReductions`

— Type`Reduction`

Represents a chain of `Reduction`

s of some ODE system. This is returned from the `find_reductions`

function.

Example:

```
using ExactODEReduction
odes = @ODEsystem(
x'(t) = x + y,
y'(t) = x - y - z,
z'(t) = 2x - z
)
reductions = find_reductions(odes)
## prints
A chain of 2 reductions of dimensions 1, 2.
==================================
1. Reduction of dimension 1.
New system:
y1'(t) = y1(t)
New variables:
y1 = x + 1//2*y - 1//4*z
==================================
2. Reduction of dimension 2.
New system:
y1'(t) = y2(t)
y2'(t) = 2*y1(t) - y2(t)
New variables:
y1 = x - 1//2*z
y2 = y + 1//2*z
reduction2 = reductions[2]
## prints
Reduction of dimension 2.
New system:
y1'(t) = y2(t)
y2'(t) = 2*y1(t) - y2(t)
New variables:
y1 = x - 1//2*z
y2 = y + 1//2*z
```

`Base.length`

— Method`length(cor::ChainOfReductions)`

Returns the number of reductions in the chain.

`Base.getindex`

— Method`getindex(cor::ChainOfReductions, i::Integer)`

Returns the `i`

-th reduction in the chain. Returned object is of type `Reduction`

.