Expression for function

I am trying to solve the equation with uniroot() , but before that I have to differentiate the expression.

I create an expression and then distinguish it with D() , but I don’t know how to return the specified expression to a function that I can take from the root.

So far, I:

 eq<-expression((w^2)*3+((1-w)^2)*2.5+2*w*(1-w)*0.9) f<-D(eq, name="w") 

Thank you in advance for your help!

+4
source share
1 answer

Try it (thanks flodel for a useful comment):

 g = function(w) eval(f) uniroot(g, c(0,1000)) 
+4
source

Source: https://habr.com/ru/post/1438145/


All Articles