change_of_variables(sys, iv, forward_subs, backward_subs) rewrites an ODE
(or SDE with brownian variables or noise equations) in new variables z = f(x): forward_subs gives f(x) ~ z and backward_subs the inverse x ~ g(z). The new equations follow from the chain rule (Itô's lemma for
stochastic systems, using the second derivative of each transformation
with respect to its own variable). Initial values of the new variables are
computed from those of the old ones.
Usage
change_of_variables(
sys,
iv,
forward_subs,
backward_subs,
simplify = TRUE,
t0 = NA,
isSDE = FALSE
)Arguments
- sys
A
System.- iv
The independent variable.
- forward_subs, backward_subs
Lists of formulas
f(x) ~ zandx ~ g(z)(or pairs).- simplify
Simplify the new equations and compile the result with
mtkcompile().- t0
Time at which initial values are computed, when they depend on time.
- isSDE
Treat the system as stochastic.
Examples
t <- t_nounits; D <- D_nounits
x <- Variable("x", t); z <- Variable("z", t); a <- Parameter("a")
sys <- mtkcompile(System(list(D(x) ~ a * x), t, name = "sys",
initial_conditions = list(x ~ 1, a ~ -0.5)))
new_sys <- change_of_variables(sys, t, list(log(x) ~ z), list(x ~ exp(z)))
equations(new_sys)
#> [[1]]
#> Derivative(z(t), t) ~ a
#>