# [R] Solving equation

Berend Hasselman bhh at xs4all.nl
Sat May 1 15:13:32 CEST 2010

```
David Winsemius wrote:
>
>
> 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
>>> 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)
>>
>
> ...
>

You could also try package nleqslv (intended for solving equations).
But also try f(0)

Berend
--
View this message in context: http://r.789695.n4.nabble.com/Solving-equation-tp2103698p2122057.html
Sent from the R help mailing list archive at Nabble.com.

```