r - How do I get the derivative of the function? -


how derivative of following function?

g <- expression(x^2) derivg <- d(g, 'x') derivg # 2 * x g1 <- derivg(2) # error: not find function "derivg" 

i want find derivative @ x = 2.

derivg call, not function. evaluate @ x = 2, can do

eval(derivg, list(x = 2)) [1] 4 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -