Skip to contents

apply_to_variables(f, ex) replaces every variable in ex (anything declared with Variable(), Parameter(), independent_variable() and the like) by f(variable) and rebuilds the expression. Derivatives keep their independent variable.

Usage

apply_to_variables(f, ex)

Arguments

f

A function of one variable returning an expression.

ex

An expression, an equation, or a list of them.

Value

The transformed expression.

Examples

t <- t_nounits
x <- Variable("x", t); k <- Parameter("k")
apply_to_variables(ParentScope, k * x)
#> k*x(t)