[R] Adding and Multiplying two Unevaluated Expressions
"Benjamin Müller"
ravenger at gmx.net
Tue Dec 1 15:41:25 CET 2009
HI,
As I'm trying to compute Taylor series, I'm having problems in adding and multiplying unevaluated expressions. I searched for a solution but found none.
my Taylor function works fine for evaluating functions as you can see here:
rTaylorVal=function(exp,x0,dx,n) {
ls=list(x=x0)
newexp=eval(exp,ls)
exp0=exp
for (i in 1:n){
exp0=D(exp0,"x")
newexp=newexp+eval(exp0,ls)/factorial(i)*dx^i
}
return(newexp)
}
Where exp is an expression like exp=expression(x^2*sin(x)), x0 is the startvalue, dx the difference between startvalue and searched value and n is the length of the series.
So I tried to remove dx as a value, to get a Taylor series expression, but it doesn't work as simple multiplication (*) and accumulation (+) is not good for expressions.
That's my point so far, now my question:
Is it actually possible to add and/or multiply expressions, and how?
Thank you so far.
Benjamin Müller
Geographer (B.Sc.)
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
More information about the R-help
mailing list