Change the independent variable of a system
Source:R/transformations-basic.R
change_independent_variable.Rdchange_independent_variable(sys, iv) turns the dependent variable iv
(for example u(t)) into the independent variable of sys. Every
variable f(t) becomes f(u), derivatives follow the chain rule
d/dt = uˍt(u) d/du with the new unknown uˍt(u) for du/dt, and the
old independent variable becomes the unknown t(u). The change is valid
when u is strictly monotonic in t.
Usage
change_independent_variable(
sys,
iv,
eqs = list(),
add_old_diff = FALSE,
simplify = TRUE,
fold = FALSE
)Details
Extra equations eqs relating the variables (such as t ~ f(u) for
non-autonomous systems) are transformed too; add_old_diff = TRUE adds
D(t(u)) ~ 1 / uˍt(u) by the inverse function rule. The change must be
made before mtkcompile(). Subsystems are transformed recursively; the
new variables are global, so iv should not be namespaced (use
GlobalScope() in subsystems).
The transformed equations are implicit in the highest derivatives (for
example uˍt^2 y'' + ...), so compiling them needs the structural
pipeline of mtkcompile().
Examples
t <- t_nounits; D <- D_nounits
x <- Variable("x", t); y <- Variable("y", t)
M <- System(list(D(D(y)) ~ -9.81, D(x) ~ 1), t, name = "M")
M2 <- change_independent_variable(M, x)
equations(M2)
#> [[1]]
#> xˍt(x)^2*Derivative(y(x), (x, 2)) + xˍt(x)*Derivative(xˍt(x), x)*Derivative(y(x), x) ~ -9.81000000000000
#>
#> [[2]]
#> xˍt(x) ~ 1
#>