Message Boards Message Boards

0
|
5348 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Obtain exact values for a multivariable optimization problem?

Posted 5 years ago

As part of my online job, I examine multiple versions of a single calculus question--the only differences in each version are some of the numerical values. As a simple example, different versions of the same question may ask for the derivative of cos(2x), the derivative of cos(3x), the derivative of cos(4x), etc., where the coefficient is randomly generated each time the question is presented.

On more calculated items, especially in multivariable calculus, checking each variation for correctness is time consuming, and I'm trying to reduce the amount of time required by using Mathematica.

After a few unsuccessful attempts (with M informing me that the answer was -infinity), I've been able to get the application to solve (one variation of) a question in which I need to minimize the cost function C = 3lw + 2lh + 2wh under the restriction that volume V = lwh = 81. Here's the code I used:

Minimize[{3 l*w + 2 l*h + 2 w*h, 
  l*w*h == 81 && l > 0 && w > 0 && h > 0}, {l, w, h}]

This produces the result: {129.[Ellipsis] , {l->81/(3.78[Ellipsis] 5.67[Ellipsis]),w->3.78[Ellipsis],h->5.67[Ellipsis]}}

Following this up with

%//N

produces nice decimal approximations:

{128.579, {l -> 3.77976, w -> 3.77976, h -> 5.66964}}

The exact values are, in order, 81 * 4^(1/3), l = 3 * 2^(1/3), w = 3 * 2^(1/3), and h = 9/2 * 2^(1/3).

As Mathematica is a symbolic system, I found it odd that it wasn't able to solve the problem with exact values, as cube roots don't seem too complex. However, I'm definitely new at Mathematica (I've been proceeding through the Elementary Intro to the Wolfram Language book over the past 2 weeks), so I may be giving M more credit that its due.

I did try using the RootApproximant function (possible incorrectly) on the Minimize[] values, as I found a post where that helped someone convert an irrational decimal output into radical notation. I also tried evaluating the results out to 100 decimal places:

N[Minimize[{3 l*w + 2 l*h + 2 w*h, 
   l*w*h == 81 && l > 0 && w > 0 && h > 0}, {l, w, h}], 100]

and then RootApproximant[]'ing each one on its own line, but that didn't produce the exact values, either.

Any advice on how I can cajole Mathematica into outputing the exact, radical versions of the solution?

POSTED BY: Dave Markham
2 Replies

Dave,

If you use @Frank Kampas 's Excellent Post on Kuhn-Tucker Minimization. You get a simpler answer for these equations. They are in the form of AlgebraicNumber expressions (which can be turned into plain root expressions with RootReduce[]. This may be a bit closer to the answer you want (for simple equations that can be analytically solved).

RootReduce[
  KKTReduce[
   3 l*w + 2 l*h + 2 w*h, {l*w*h == 81, l > 0, w > 0, h > 0}, {l, w, 
    h}]] // InputForm

to get

{2*h*l + 2*h*w + 3*l*w, {Root[-54 + #1^3 & , 1, 0] -> l, Root[-54 + #1^3 & , 1, 0] -> w, 
  Root[-729 + 4*#1^3 & , 1, 0] -> h, \[Lambda][1] -> Root[32 + 27*#1^3 & , 1, 0]}}

Frank may be able to give you more insight...

Regards,

Neil

POSTED BY: Neil Singer

The problem is solved in terms of roots of polynomial, which are represented, in Version 12, as numerical values. InputForm will give you the polynomial root form

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract