[R] Fwd: Re: Nonlinear equation

Ravi Varadhan rvaradhan at jhmi.edu
Wed Apr 2 17:48:28 CEST 2008


Here is an approach using optim().

fn <- function(x, A, B) {
(2*lgamma(x) + lgamma(2*x)+ (x-1)*A + B)^2
}

ans <- optim(par=1, fn, A=1.5, B=1.0, method="BFGS")

You should plug in your values for A and B.  Make sure that the function
value returned ny optim, i.e. ans$val, is close to zero.  If not, try a
different starting value.

Ravi.
----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of robert-mcfadden at o2.pl
Sent: Wednesday, April 02, 2008 11:25 AM
To: r-help at r-project.org
Subject: [R] Fwd: Re: Nonlinear equation

> > >From: robert-mcfadden at o2.pl
> > >Date: 2008/04/02 Wed AM 09:58:28 CDT
> > >To: r-help at r-project.org
> > >Subject: [R] Nonlinear equation
> > 
> > hi: you need to give an example and details or
> > you won't get much response, if any.

Equation e.g. (A, B are known constants):
3log(gamma(x))-log(gamma(x)*gamma(2x))+(x-1)*A+B=0

______________________________________________
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.



More information about the R-help mailing list