Say I have a function $f(x,y)$ that depends on two variables. How can I find the maximum of the function $f(x,y) \big|_{y = constant}$ for every value of $y$ and plot the value of $f(x_{max}(y), y)$ vs $y$? (I.e. $x_{max}(y)$ is the minimum of the function for a given value of $y$.)
So this would plot the trajectory of the maxima, which could be seen as a ridge of the function.
The solution does not have to be analytic, numerical is fine.
Example:
f = -(x^2 + 1)*(y^2 + 1)
DensityPlot[f, {x, -10, 10}, {y, -10, 10}, PlotRange -> Automatic, PlotLegends -> Automatic, MaxRecursion -> 10]
Plot[f /. x -> 0, {y, -10, 10}]
So here it is trivial to find the maximum of the function at constant $y$, it is simply $x_{max}(y)=0$. The desired plot is the last one, except that instead of f/.x->0
a function that finds the maximum at each $y$ is required.
Plot[NMaxValue[-(x^2 + 1)*(y^2 + 1), x], {y, -10, 10}]
? $\endgroup$