Let N be a real number > 0.
Given a function in k real, distinct variables, where the sum of the variables has to equal N, how would I go about finding the configuration of the k variables for which the function has the maximum possible value?
Example:
$N = 100;$
$ Z = 3a + 5b + sin(c) - d(e^2) $
How would I find the values of $a,b,c,d,e$ for which $Z$ is max, where $a+b+c+d+e = N$ ?
I am looking for something that will work for any n number of variables, and N of any size.
To simplify the notation, let $x=(a, b, c, d, e) \in \mathbb{R}^n$ and $g(x)=a+b+c+d+e -N$. Then you can use Lagrange multipliers which in this case means, that $\nabla Z = \lambda \nabla g$ at the maximum. Geometrically, the constraint $g=0$ defines a $n - 1$ dimensional manifold (in your case just a plane with the parametrization $e= a+b+c+d - N$) and the gradient has to be perpendicular to that manifold.
The alternative is, you use the implicit function theorem (or another method) to solve the constraint equation and then you get a coordinate chart $\varphi: \mathbb{R}^n \to S = \{ y\in \mathbb{R}^n : g(y)=0\}$ which you can use to analyze the function $Z\circ \phi : \mathbb{R}^n \to \mathbb{R}$ by standard calculus methods.