# Plot with substitution of domain values before evaluation of function

I have a function of two variables $$f(x,y)$$. I find the maximum value of $$f(x_0,y)$$ by first substituting the value of $$x=x_0$$ and then maximizing in the range $$0.

My question is: How to plot a function with first substituting a value of $$x=x_0$$ and then getting out a value fromFindMaximum for a range of values $$1?

MWE:

f[x_] := (x + y)^2;
Plot[FindMaximum[{f[x], 0 < y < 1}, y], {x, 1, 2}]


f[x_] := (x + y)^2;

obj[x_?NumericQ] := FindMaxValue[{f[x], 0 < y < 1}, y]

• @kaka You're welcome. I suppose it would likely be obj[x0_?NumericQ, y0_?NumericQ, z_?NumericQ] := f[x0, y0, z], but it could depend on the details of the function and its use. – Michael E2 Oct 6 at 19:51