[R] taylor expansions with real vectors

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jul 18 22:55:05 CEST 2012


On Wed, Jul 18, 2012 at 9:47 AM, bilelsan <sanbilel at yahoo.fr> wrote:
> Dear list,
>
> I have a big deal concerning the development of a Taylor expansion.
>
> require(Matrix)
> e1 <- as.vector(1:5)
> e2 <- as.vector(6:10)
>
> in order to obtain all the combinations between these two vectors following
> a Taylor expansion (or more simply through a Maclaurin series) for real
> numbers.
> We have f(x) = f(0) + f'(0)(x-0) + f''(0)(x-0)^2/2! + … + f^(k)(0)(x-0)^k/k!
> with
> f(x) = e1 + e2 for Taylor expansion (r = 1)
>         + 1/2!*e1^2 + 1/2!*e2^2 + 1/2!*e1*e2 for Taylor expansion (r = 2)
> excluding e2*e1
>         + 1/3!*e1^3 + 1/3!*e1^2*e2 + 1/3!*e2^2*e1 + 1/3!*e2^3 for Taylor
> expansion (r = 3) excluding e2*e1^2 and e1*e2^2
>        ...
> I already write the number of possible combinations as :
> x <- as.vector(0)
> for (r in 1:r){x[r] <- 2*(sum(choose(2*q+r-1,r))-sum(choose(q+r-1,r)))}# q:
> number of lag of e1 and e2; r: order of taylor expansion
> nstar   <- sum(x) # N* number of total combinations
>
> How to write f(x) in a general framework?
> Quid of this framework when e1 and e2 are completed with their lags if q >
> 1?
> Your help or advice would be greatly appreciated
>

See the section on Taylor expansions in the Ryacas package vignette.
Depending on what you want to do that may or may not be relevant.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list