From adelchi.azzalini@jrc.it  Mon Apr 26 10:12:35 1999
From: adelchi.azzalini@jrc.it (Adelchi Azzalini)
Date: Mon, 26 Apr 1999 10:12:35 +0100
Subject: [S] uniroot -- doesn't work recursively
References: <199904220944.LAA10647@gwen.stat.unipd.it.> <199904231713.TAA15277@sophie.ethz.ch> <x2yajhh9in.fsf@blueberry.kubism.ku.dk>
Message-ID: <37242E03.63BEAB06@jrc.it>

Martin Maechler wrote:

) However, note that R currently has the same problem as S-plus:

) Uniroot() doesn't work reliably, recursively.
) When you found it to be better, you were just lucky.

Right.  I realised later on that R seemed to behave better but 
it could not work properly since it calls a Fortran (66? 77?) routine.
It just happen to produce less obviously wrong answers than Splus.
In fact more tests confirm wrong answers, but not as non-sensical 
as those from Splus.

To get around the problem,  I have replaced  f(x)=0 by f^2(x)=min,
where f(x)is computed with the aid of uniroot(), and the minimization
is solved by optimize(). This works.

Peter Dalgaard BSA wrote:
> 
> Martin Maechler <maechler@stat.math.ethz.ch> writes:
> 
> 
> Well, uniroot calls zeroin which is a FORTRAN routine. As long as this
> is the case, all bets are off as to whether or not it will be
> reentrant on any given system. In principle, it is not, and FORTRAN
> just plain states that "you cannot do that", but if your compiler
> happens to be f2c-like, and no global storage is involved, then it
> *might* work after all. The example doesn't work on my system either.
> 
> The only sensible thing to do to get this to work is to rewite zeroin
> in C. According to the comments in the file, it is a transcription of
> an Algol60 program, so it is probably not hard to convert it to
> another Algol descendant.
> 

My R 0.64 is obtained from the binary file distributed by CRAN in Wien
(compiled by Guido Masarotto?), so I do not know which the compiler is 
used.

Thanks for your comments

Regards
Adelchi Azzalini
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[S] uniroot -- doesn't work recursively
Adelchi Azzalini