I asked a similar question earlier but my question wasn't clear. Here's another attempt.
Suppose you have the following function that takes two inputs, a and b.
inputs <- c(a, b)
y <- function(inputs) {
a <- inputs[1]
b <- inputs[2]
output <- a/100 * (20 * b)^0.8 + (100 - a) / 100 * (10 * (100 - b))^0.8
return(output)
}
For all possible values of a in the range [0, 100], I want to find the value of b that maximizes the output of the function above, with the restriction that b also has to be a value in the range [0, 100].
In other words, I want to plot b as a function of a, such that b maximizes the output value of the function above for the given value of a.
How would you write the code for this?