x2logx: Log-transform variables in an equation vector using SymPy

View source: R/eqnClass.R

x2logxR Documentation

Log-transform variables in an equation vector using SymPy

Description

Log-transform variables in an equation vector using SymPy

Usage

x2logx(eqnvec, whichVar)

Arguments

eqnvec

An object of class eqnvec, representing a set of equations.

whichVar

A character vector specifying the variables to be log-transformed.

Details

The function applies a logarithmic transformation to the specified variables in the equation vector. For a variable var, the transformation is log(var) and the derivative d/dt log(var) is replaced by (1/exp(log(var))) * d/dt var, substituting var with exp(log(var)) in the original equation. The original variable equations are replaced or removed, and the transformed equations are added with updated names prefixed by log_. The equations are simplified using SymPy to ensure mathematical correctness and compactness.

Value

An updated eqnvec object with transformed equations.

Examples

eqnvec <- as.eqnvec(
  c("-k1*A + k2*B", "k1*A - k2*B"),
  names = c("A", "B")
)
log_transformed_eqns <- x2logx(eqnvec, c("A", "B"))


dkaschek/dMod documentation built on June 12, 2025, 2:50 a.m.