# Maximize and minimize R6 function using Lagrange Multipliers

I've been trying to maximize and minimize the following function using Lagrange Multipliers, in Wolfram Mathematica 11.3:

d = Sqrt[x^2 + y^2 + z^2 + u^2 + v^2 + w^2]

Subject to the following constraints:

g = x + y + z + u + v + w - 1 and h = x^2 + y^2 + z^2 + u^2 + v^2 - 1

What I've tried so far is the following:


Gd = {D[d, x], D[d, y], D[d, z], D[d, u], D[d, v], D[d, w]}

Gg = {D[g, x], D[g, y], D[g, z], D[g, u], D[g, v], D[g, w]}

Gh = {D[h, x], D[h, y], D[h, z], D[h, u], D[h, v]}

system = {Gd[] == \[Lambda] Gg[] + \[Micro] Gh[],
Gd[] == \[Lambda] Gg[] + \[Micro] Gh[],
Gd[] == \[Lambda] Gg[] + \[Micro] Gh[],
Gd[] == \[Lambda] Gg[] + \[Micro] Gh[],
Gd[] == \[Lambda] Gg[] + \[Micro] Gh[],
Gd[] == \[Lambda] Gg[], g == 0, h == 0};
% // MatrixForm


And then a little Solve function:

sist = Solve[system, {x, y, z, u, v, w, \[Lambda], \[Micro]}]


After executing, it just keeps running forever. Any ideas on how to make it easier?

• Are Lagrange multipliers required for some reason? One can simply do this using Maximize. It will be easier if the Sqrt[] is dropped (makes no difference to the arg max). – Daniel Lichtblau Nov 18 '19 at 18:07

For the minimum, you can use NMinValue. I changed it up to use some Region functionality:

NMinValue[{Sqrt[v.v+w^2], Total[v]+w==1, v ∈ Sphere},{v, w}]


1.

Or, you can use explicit scalars:

NMinValue[{Sqrt[x^2+y^2+z^2+u^2+v^2+w^2], x+y+u+v+w==1&&x^2+y^2+z^2+u^2+v^2==1},{x,y,z,u,v,w}]


1.

I'm not sure if using MinValue would ever finish.

For the maximum, you can use MaxValue:

MaxValue[{Sqrt[v.v+w^2], Total[v]+w==1, v ∈ Sphere},{v, w}]


Sqrt[7 + 2 Sqrt]

Or, using explicit scalars:

MaxValue[{Sqrt[x^2+y^2+z^2+u^2+v^2+w^2], x+y+z+u+v+w==1&&x^2+y^2+z^2+u^2+v^2==1},{x,y,z,u,v,w}]


Sqrt[7 + 2 Sqrt]

Use NMinimize and Maximize if you want the location of the extrema as well as the value.