Optimization 11-24-2020

Calculus Level 2

Find the maximum value of the quantity x + 2 y + 2 z 2 x + 2y + 2 z^2 , subject to the constraint x 2 + y 2 + z 2 = 1 x^2 + y^2 + z^2 = 1 .


The answer is 2.625.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Joseph Newton
Nov 24, 2020

Using z 2 = 1 x 2 y 2 z^2=1-x^2-y^2 , we have x + 2 y + 2 z 2 = x + 2 y + 2 ( 1 x 2 y 2 ) = 2 + x 2 x 2 + 2 y 2 y 2 = 2 2 ( x 1 4 ) 2 + 1 8 2 ( y 1 2 ) 2 + 1 2 2 + 1 8 + 1 2 = 21 8 = 2.625 \begin{aligned}x+2y+2z^2&=x+2y+2(1-x^2-y^2)\\ &=2+x-2x^2+2y-2y^2\\ &=2-2\left(x-\frac14\right)^2+\frac18-2\left(y-\frac12\right)^2+\frac12\\ &\leq2+\frac18+\frac12\\ &=\frac{21}8=2.625\end{aligned} This value of 21 8 \frac{21}8 is attained at x = 1 4 x=\frac14 and y = 1 2 y=\frac12 , hence z 2 = 1 1 16 1 4 = 11 16 z^2=1-\frac1{16}-\frac14=\frac{11}{16} , so z = ± 11 4 z=\pm\frac{\sqrt{11}}4 . Hence, this maximum is attained at a legitimate point ( x , y , z ) (x,y,z) .

Karan Chatrath
Nov 24, 2020

The constrained optimization problem can be converted to an unconstrained optimization problem by recognising that the optimal solution must lie on the unit sphere. This means:

x = sin θ cos ϕ ; y = sin θ sin ϕ ; z = cos θ x = \sin{\theta} \cos{\phi} \ ; \ y = \sin{\theta} \sin{\phi} \ ; \ z = \cos{\theta}

0 θ π ; 0 ϕ 2 π 0 \le \theta \le \pi \ ; \ 0 \le \phi \le 2 \pi

This converts the cost function to:

F = sin θ cos ϕ + 2 sin θ sin ϕ + 2 cos 2 θ F = \sin{\theta} \cos{\phi} + 2 \sin{\theta} \sin{\phi} + 2\cos^2{\theta}

Now, one can compute the partial derivative of F F with respect to θ \theta and ϕ \phi and proceed from there, but I have resorted to a shortcut. I swept across the parameter space using a short script of code which is attached below. Code is commented. The maximum value is 2.625 \boxed{\approx 2.625} .

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
clear all
clc

% Numerical resoloution:
dphi   = pi/1000; dtheta = pi/1000;

% Variable counter:
c = 1;

% Nested loop to sweep over the the unit sphere:
for theta = 0:dtheta:pi
    for phi = 0:dphi:2*pi

        % Cost function evaluation:
        F(c)  = sin(theta)*cos(phi) + 2*sin(theta)*sin(phi) + 2*cos(theta)^2;
        c     = c + 1;
    end
end

% Printing maximum value:
max(F)

Tom Engelsman
Nov 25, 2020

Substituting the spherical constraint in for z 2 z^2 gives us a function in two variables f ( x , y ) = x + 2 y + 2 ( 1 x 2 y 2 ) = x + 2 y 2 x 2 2 y 2 + 2. f(x,y) = x + 2y + 2(1-x^2-y^2) = x+2y-2x^2-2y^2+2. Taking g r a d f = 0 grad f = 0 yields:

f x = 1 4 x = 0 x = 1 4 , f_{x} = 1-4x = 0 \Rightarrow x =\frac{1}{4},

f y = 2 4 y = 0 y = 1 2 . f_{y} = 2-4y=0 \Rightarrow y = \frac{1}{2}.

The Hessian Matrix of f f computes to:

F ( x , y ) = [ 4 0 0 4 ] = 4 I 2 x 2 F(x,y) = \begin{bmatrix} -4 & 0 \\ 0 & -4 \end{bmatrix} = -4 \cdot I_{2x2}

which is negative-definite for all x , y R . x,y \in \mathbb{R}. Hence, the maximum value of f f is just f ( 1 4 , 1 2 ) = 2.625 . f(\frac{1}{4},\frac{1}{2}) = \boxed{2.625}.

Fletcher Mattox
Nov 25, 2020
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from scipy.optimize import minimize

def f(x):
    a,b,c = x
    return -(a + 2*b + 2*c**2)

def constraint(x):
    a,b,c = x
    return a**2 + b**2 + c**2 - 1

cons=({'type':'eq','fun':constraint})
x0 = [1, 1, 1]
res= minimize(f,x0,method='SLSQP',constraints=cons)
print(-res.fun)

1
2.6250000471897614

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...