Ask Your Question
1

find maximum value of F

asked 2020-10-14 11:45:51 +0200

Dalin Aranga gravatar image

F = (4x+4y+9z-2w), G = (2x+2y +z+ w)==0, H = (x^2+y^2+z-4)==0,

  • x ,y, z, w is symbolic expressions in 4 variables.
  • The symbolic expressions G and H represent constraints.
  • find the maximum value of F , subject to the constraints G=0 and H=0 ?????????

  • please help me

edit retag flag offensive close merge delete

Comments

Homework ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-10-14 13:14:09 +0200 )edit

Use Lagrange multipliers?

slelievre gravatar imageslelievre ( 2020-10-15 00:17:18 +0200 )edit

Where are you stuck?

slelievre gravatar imageslelievre ( 2020-10-15 13:50:04 +0200 )edit

Still homework or not ?

Hint : the maximum you seek is $\displaystyle\frac{516}{11}$...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-10-16 15:52:14 +0200 )edit

Another hint : in your specific case, Lagrange multipliers are not strictly necessary, and a high school-level method is sufficient...

Nevertheless, looking up "Lagrange multipliers" in Wikipedia and understanding it is strongly advisable, event if the rigorous proofs underlying it require a bit more analysis than high school-level... (Anyway, high school-level analysis postulates some properties of the real numbers, whose proof requires way more than high school-level algebra and topology (the latter being null IIRC...)).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-10-16 16:18:28 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-10-21 21:14:45 +0200

Emmanuel Charpentier gravatar image

updated 2020-10-22 07:51:20 +0200

One week after, we still don't know if this is homework or not. Well... one week after, it might be stale. So here are a couple of answers to a question interesting beyond the OP's potential homework.

The problem data can be set up in Sage as follows:

# Problem data
# Arguments of the function to optimize and nullity constraints to satisfy
Args = var("w, x, y, z")

# Function to optimize (here a symbolic expression)
F = (4*x + 4*y + 9*z - 2*w)

# Constraints (here, symbolic expressions to nullify)
G = (2*x + 2*y + z + w)
H = (x^2 + y^2 + z - 4)

# Problem setup: tuple of constraints -- expressed in
# a way that does not depend on the particular problem
C = (G, H)

General solution

The general solution states that if (the $n$-dimensional vector) $\mathbf{x_0}$ maximizes (the scalar) $\phi(\mathbf{x})$ under the ($m$-vector) equality constraint $\boldsymbol{\psi}\mathbf{(x}) = \mathbf{0}$, then there exist an ($m$-dimensional) vector $\mathbf{\lambda}$ (the Lagrange multipliers) such as all the components of the differential of the (scalar) function (callad Lagrangian) $\phi(\mathbf{x_0})+ \mathbf{\lambda} \cdot \mathbf{\boldsymbol{\psi}(x_0)}$ are all zero; in other words, the maximization of a scalar function of $n$ variables under $m$ constraints is replaced by the maximization of a scalar function of $n + m$ variables.

This translates in Sage as:

# Solution
# (Vector) function of constraints
psi = vector(C).function(*Args)

# Vector of Lagrange multipliers
Lambda = vector([var("lambda_{}".format(u)) for u in range(len(C))])

# Function to optimize
phi = F.function(*Args)

# Lagrangian arguments
ArgsL = Args + tuple(Lambda)

# Lagrangian function
L = (phi + Lambda.dot_product(psi)).function(*ArgsL)

# Its differential (vector)
dL = L.diff()(*ArgsL)

# Solution(s) nullifying this differential :
Sol = solve(list(dL), ArgsL, solution_dict=True)

# Extremal value
Max = F.subs(Sol)

which gives:

sage: Sol
[{w: -628/121, x: 4/11, y: 4/11, z: 452/121, lambda_0: 2, lambda_1: -11}]
sage: Max
516/11

Nota bene: the Lagrange multipliers solutions can be maxima or minima, but may also be saddle points; this should be checked.

Specialized solution

The idea is to use the $m$ constraints to express $m$ variables as functions of the other $n - m$ variables. (Here, we can express $w$ and $z$ as functions of $x$ and $y$). The problem is then to find the (unconstrained) maximum of a function of $n - m$ variables, which is done by solving the components of its differential for those variables.

This is called parameterization.

# Eliminate two variables from the two constraints. Here, we choose w and z,
# since one constraint uses x^2 and y^2, opening the door to multiple solutions
S1 = solve([G, H], [w, z], solution_dict=True)

# Substitute this in F
F1 = F.subs(S1)

# Optimize F1, i. e. find the point(s) where both derivatives are zero
Sol1 = solve([F1.diff(u) for u in (x, y)], [x, y], solution_dict=True)

# Substitute in the [G, H] system, and solve for (numerical) w, z
Sol2 = solve([u.subs(Sol1[0]) for u in (G, H)], [w, z], solution_dict=True)

# Cleanup: One dictionary solution
HSSol = copy(Sol1[0])
HSSol.update(Sol2[0])

# Get the (numerical) extremum
HSMax = F.subs(HSSol)

which gives:

sage: HSSol
{x: 4/11, y: 4/11, w: -628/121, z: 452/121}
sage: HSMax
516/11

Again, the nature (maximum, minimum or saddle-point) of the extrema thus obtained must be checked.

Numerical solutions

One can note that Sage implements numerical methods of minimization of a real function subject to (more general inequality) constraints, accessible via the minimize_constrained function. Other methods implemented in SciPy (which Sage depends on) can also be used.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-14 11:45:51 +0200

Seen: 1,022 times

Last updated: Oct 22 '20