Dear community,

I am pretty new in R and due to the fact that I am totally desperate, I really hope someone has the time to help me to solve my problem:

I want to find the solution for the following equation, where lowercase variables are known and given as variables, uppercase (X) is the one i want to solve for:

0 = a/(X*b-min(c,b*X)) - d

I thought it would be good to solve by finding the minimum of the RHS of the equation and translate the min() argument in inequality constraints as follows

min(a/(X*b-Y) - d)
s.t. Y-c =< 0, Y-b=<0,
-(a/(X*b-Y) - d )=<0

I added the third inequality constraint because otherwise my initial function is not going to be equal to zero but highly negative.

It is probably a very easy equation to solve, and I might have done too many steps due to the fact that I am not a big programmer, but here is my code how I tried to solve it, whick gives me errors unfortunately:

```
library(nloptr)
myfun<- function(X,Y,a,b,d){
return(a/(X*b-Y) - d)}
eval_g_ineq <- function(X,Y,a,b,c,d,){
return(c(Y-c , Y-b, -(a/(X*b-Y) - d)))}
opts = list("algorithm"="NLOPT_LD_MMA",
"xtol_rel"=1.0e-4) # here I dont know if I use the right algorithm but I got errors before alerady
#here comes my optimization function:
nloptr(x0=1, eval_f=myfun, eval_g_ineq = eval_g_ineq, lb=0, ub=Inf, opts=opts,
a=100, b=20, c=30, d=1)
```

And here comes my error:

```
Error in .checkfunargs(eval_f, arglist, "eval_f") : eval_f requires argument 'Y' but this has not been passed to the 'nloptr' function.
```

I also tied to specify two optimization values (for X and Y) as x0=c(1,1), lb=c(0,0), ub=c(Inf,Inf) but it didn't work. Is any one out there that is so kind and could give me some hints? Many many thanks in advance!

Best, Hans