I have to compute a product of 3 matrices D=ABC
with:
The result of this product is a simple value, and the calculation is very straightforward in R.
My problem is there is one unknown, namely X
, inside A
and C
, and I would like to get the result as a formula: D = ABD = f(X)
.
Is there any way I could achieve this with R ?
Define D
as shown below where argument B
is the square matrix and A
is a function of x
returning a vector.
D <- function(B, A) function(x) t(A(x)) %*% B %*% A(x)
# test
A <- function(x) seq(3) * x
B <- matrix(1:9, 3)
Dfun <- D(B, A)
Dfun(10)
## [1] 22800