Skip to content
Prev 244458 / 398503 Next

Dynamically build functional expression and taking derivative

Hi!

I'm faced the next problem:
suppose I have a vector of some coefficient and for some purpose from  
these coefficients I need dynamically build a functional expression  
(because, the number of elements in the vector of coefficients might  
differ each time). So, I'm trying to do like this (let the number of  
coefficients be 3):

Building expression
[1] "(p1*x + (1-p1))* (p2*x + (1-p2))* (p3*x + (1-p3))"

But now, how can I take derivative of this expression w.r.t. "x"?
May be there are other ways to handle this kind of situation?


Best regards,
Oleksandr