[Rd] uniroot arguments (PR#9140)

trish at maigret.psy.ohio-state.edu trish at maigret.psy.ohio-state.edu
Fri Aug 11 15:27:19 CEST 2006


<<insert bug report here>>

When invoking "uniroot" with any argument named "u", uniroot exits
with error: "Error in f(lower, ...) : argument "u" is missing, with no
default".  This error occurs whether or not "u" determines the root.

Giving "u" a default value results in garbage from uniroot.

## Define a function with a root:
> test<-function(x,a) (x-a)^3

## Find the root:
> uniroot(test,c(0,1),a=.75)
$root
[1] 0.7500141

$f.root
[1] 2.793453e-15

$iter
[1] 22

$estim.prec
[1] 6.103516e-05

## All is well.  Change argument "a" to "u":
> test<-function(x,u) (x-u)^3
## Plot it:
> plot(seq(0,1,by=.1),test(seq(0,1,by=.1),u=.75),type='l')

## All is well.  Find the root:
> uniroot(test,c(0,1),u=.75)
Error in f(lower, ...) : argument "u" is missing, with no default

## Define a new function with the same root:
> test<-function(x,a,u) (x-a)^3 /u
## Plot it:
> plot(seq(0,1,by=.1),test(seq(0,1,by=.1),a=.75,u=.2),type='l')

## All is well.  Find the root:
> uniroot(test,c(0,1),a=.75,u=.2)
Error in f(lower, ...) : argument "u" is missing, with no default

## Give u a default value:
> test<-function(x,a,u=.2) (x-a)^3 /u
## Find the root:
> uniroot(test,c(0,1),a=.75,u=.2)
Error in uniroot(test, c(0, 1), a = 0.75, u = 0.2) :
        f() values at end points not of opposite sign

## Oh, really?
> test(0,.75,.2)
[1] -2.109375
> test(1,.75,.2)
[1] 0.078125




--please do not edit the information below--

Version:
 platform = i686-redhat-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = 
 major = 2
 minor = 2.1
 year = 2005
 month = 12
 day = 20
 svn rev = 36812
 language = R

Locale:
C

Search Path:
 .GlobalEnv, package:methods, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, Autoloads, package:base



More information about the R-devel mailing list