# Re: [R] code for power and suffix for x,y labels in plot( ).

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Wed, 02 Jun 2010 09:15:40 -0700

On Tue, Jun 1, 2010 at 9:59 PM, Shant Ch <sha1one_at_yahoo.com> wrote:
> Hi
>
> I was trying to have a graph whose axes are X axis: m, Y axis: var[X ((a,b) in suffix, and (n,d) in the power)].
>
> X ((a,b) in suffix, and (n,d) in the power)-        X^(n,d) _ (a,b).
>
> Actually I require many plots involving different values of a,b,n,d, so need to keep this complicated notation.
> The expression() didn't work out for this case. Can anyone help me out.
> Shant
>
>
>
>
>
>
> uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2, upper = 2, tol = 0.001 )
>
> 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.

temp.fun <- function(x) {
value <- x*(3^x)*log(4)-x*log(4/3)-(3^x)+1   return(value)
}

look what happens when you do:

temp.fun(-2)
temp.fun(2)

in both cases, it returns a positive value. uniroot() requires "The function values at the endpoints must be of opposite signs (or zero)", hence the error. I believe your function has a lower bound of 0, which is obtained when the input is 0. So one option would be to change your argument to uniroot() so that lower=0. Although the results are not particularly interesting in this case.

uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = 0, upper = 2, tol = 0.001 )

HTH, Josh

>
>
> Shant
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

```--
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help