Hi, all I'm trying to solve an optimization problem with two variables, in wich I use the following functions(they all are working perfectly): FxMixedALT=function(x){calc=(-0.88*exp((-1.53655/10000000)*(x^5.3)))-(0.12*exp(-0.06415*(x^2.5)))+0.88+0.12return(calc)} RxMixedALT=function(x){calc=1-FxMixedALT(x)return(calc)} SUM=function(x){T1=x[1]M1=x[2]n=M1-1calc5=1:nfor (i in 0:n){if(i==0) {pterm=RxMixedALT(i*T1)} else {calc5[i]=RxMixedALT(i*T1)}}y=sum(calc5)+ptermreturn(y)} U=function(x){T1=x[1]M1=x[2]y=T1*M1calc7=integrate(RxMixedALT,0,y,stop.on.error = FALSE)return(calc7$value)} V=function(x){T1=x[1]M1=x[2]y=T1*M1calc6=((T1*SUM(x))+(0.001*RxMixedALT(y))+(0.00463*FxMixedALT(y)))return(calc6)} D=function(x){T1=x[1]M1=x[2]calc7=V(x)-U(x)return(calc7)} CM=function(x){T1=x[1]M1=x[2]y=T1*M1calc9=1*SUM(x)+12*RxMixedALT(y)+18*FxMixedALT(y)return(calc9)} CT=function(x){T1=x[1]M1=x[2]calc10=CM(x)+60*D(x)return(calc10)} A=function(x){T1=x[1]M1=x[2]calc11=U(x)/V(x)return(calc11)} C2=function(x){T1=x[1]M1=x[2]calc12=CT(x)/V(x)return(calc12)} However, when I use the optim() fuction there is an error message that says:> optim(c(0,0),C2)Error in integrate(RxMixedALT, 0, y, stop.on.error = FALSE) : non-finite function value I would like to know a way to solve this problem. Any help will be welcome! Claudio [[alternative HTML version deleted]]