[R] R solve equation

rafamoral rafa_moral2004 at yahoo.com.br
Sun Feb 8 23:05:11 CET 2009


If you are looking for a solution to a polynomial equation with imaginary
solutions you could use polyroot().
Example:
To solve the equation: 1 + x + x^3 + 2*x^4 = 0
you create a vector with the coefficients of x and use polyroot:

z <- matrix(c(1,1,0,1,2), ncol=1)
polyroot(z)

Also try ?polyroot

Rafael



Paul Smith wrote:
> 
> On Sat, Feb 7, 2009 at 10:20 AM, oryie <43248523 at qq.com> wrote:
>> I want to use R to calculate the variable x which is in some eqation,
>> give
>> an example:
>>
>> 3*x-log(x)+1=0,
>>
>> how to solve equation to get the exact x in R?
> 
> You could use uniroot(), but your equation has no real solution.
> 
> Paul
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/R-solve-equation-tp21886831p21903933.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list