Skip to content

Matrices in R - Simple question?

2 messages · Lars Bishop, David Winsemius

#
I suspect you probably need to provide an example that illustrates why  
this seems difficult:

 > x <- 1:10
 > f1 <- function(x) exp(x)
 > g1 <- function (x) log(x)
 > h1 <- function (x) x^(1/2)
# any of these functions would return a 10 element vector if given x  
as an argument

 > f1(x)*g1(x)*h1(x)
  [1] 0.000000e+00 7.243182e+00 3.821981e+01 1.513782e+02 5.341111e+02  
1.770607e+03 5.645900e+03 1.753265e+04 5.341289e+04
[10] 1.603838e+05

 > sum( f1(x)*g1(x)*h1(x) )
[1] 239476.8

Examples might help ....