[R] Solving equation
David Winsemius
dwinsemius at comcast.net
Sat May 1 13:49:42 CEST 2010
On May 1, 2010, at 3:28 AM, Berend Hasselman wrote:
>
>
> Shant Ch wrote:
>>
>> I want to solve: x*(3^x)*log(4)-x*log(4/3)-(3^x)+1=0 for x. I used
>> the
>> following code,
>>
>> uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2,
>> upper =
>> 2, tol = 0.001 )
>>
>> While using this I am getting the following error. Can anyone
>> please help
>> me out.
>> Error in uniroot(function(x) x * (3^x) * log(4) - x * log(4/3) -
>> (3^x) +
>> : f() values at end points not of opposite sign.
>>
> Try f(-2) and f(2) and you'll see the cause of the error message.
> Define your equation as a function
>
> f <- function(x) return(x*(3^x)*log(4)-x*log(4/3)-(3^x)+1)
>
> and do
>
> curve(f,from=-2,to=2)
>
> curve(f,from=-.1,to=.1)
>
> and draw your conclusions.
Try optimize instead.
--
David.
>
> Berend
> --
> View this message in context: http://r.789695.n4.nabble.com/Solving-equation-tp2103698p2108544.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list