Dear All, Hello!

I have some questoins in R programming as follows:

Question 1- How to take the integral of this function with respect to y, such 
that x would appear in the output after taking integral.

f(x,y)=(0.1766*exp(-exp(y+lnx))*-exp(y+lnx))/(1-exp(-exp(y+lnx))) y in 
(-6.907,-1.246)

It is doable in maple but not in R. At least I could not find the way.

p.s: result from maple is:

g(x)=dilog*exp(0.001000755564*x)+0.5*ln(exp(0.001000755564*x))^2-dilog*(exp(0.2876531111*x))-0.5*ln(exp(0.2876531111*x))^2

Where dilog=integral(log(t)/(1-t)) for t in (1,x)



Question 2- Then I want to optimize (maximize) the answer of the above integral 
for x. Assum x in (0,100)

The answer should be something between 26 and 27.



What I did is: got answer of integral(f(x,y)) from maple which is g(x), and 
then applied it in R. The code is as follows:

##In the case n=1

library(stats)
require(graphics)
integrand=function(t){(log(t))/(1-t)}
#dilog=integrate(integrand, lower=1, upper=x)
fr <- function(x){(integrate(integrand, lower=1, 
upper=x)$value)*(exp(0.001000755564*x))+0.5*log(exp(0.001000755564*x))^2-(integrate(integrand,
 lower=1, upper=x)$value)*(exp(0.2876531111*x))-0.5*log(exp(0.2876531111*x))^2}

optim(20, fr, NULL, method = "BFGS")



Question 2-1-Default by optim is to minimize a function, how I can use it to 
maximization?



Question 2-2- The above code faced with errors, and did not work. What I guess 
is there is something wrong with taking integral. The output of integrate 
function in R is some sort of thing. I had to somehow tell it, just take the 
value and forget about the others. But I guess it is still something wrong with 
it. I also tried maxNR, but is didn't work either.



Question 2-3- Thoes above are the easiest case of my problem. Assume the case 
that I have summation of f(x1,y)+f(x2,y)+...+f(x12,y)



The article have done it by E04JAF-NAG Fortran Library Routine Document. But I 
want to do it in R.

Thanx all.



Cheers,

Maryam

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to