Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要计算一个导数,比如 f = x^2。我正在使用代码
D(expression(x^2), 'x')
如何使用 D(x^2) = 2x 的输出作为将取值的函数?
k<-deriv(~ x^2, "x") x <- -1:10 eval(k)
这是一种将结果转换为函数的方法:
> myfun <- function(x) {} > body(myfun) <- D( expression(x^2), 'x' ) > > myfun( 1:10 ) [1] 2 4 6 8 10 12 14 16 18 20