Skip to content
Prev 301626 / 398503 Next

taylor expansions with real vectors

On Sun, Jul 22, 2012 at 05:34:08PM -0700, bilelsan wrote:
Hi.

I am sorry for a late reply. I was on vacations one week.

Can you specify the problem?

I get

  e1 <- 2
  e2 <- 3
  k <- 3
  f <- 0 
  for (r in 1:k) { 
     f <- f + 1/factorial(r) * sum(e1^(r:0)*e2^(0:r)) 
  } 
  f

  [1] 25.33333

If this the correct answer?

The code may be put to a function.

  getF <- function(e1, e2, k)
  {
      f <- 0 
      for (r in 1:k) { 
          f <- f + 1/factorial(r) * sum(e1^(r:0)*e2^(0:r)) 
      } 
      f
  }

  getF(2, 3, 3)

  [1] 25.33333

Hope this helps.

Petr Savicky.