Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Constrained Optimization

  • To: mathgroup at
  • Subject: [mg57659] Re: [mg57609] Constrained Optimization
  • From: "David Park" <djmp at>
  • Date: Fri, 3 Jun 2005 05:33:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


Don't you need to maximize over two variables?

f[x_, y_] := (x - x^2) y
Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, {x, y}]
{Infinity, {x -> Indeterminate, y -> Indeterminate}}

You still obtain an error message but that is because there is no maximum on
the domain.

If you restrict the y domain you will obtain a maximum.

Maximize[{f[x, y], 1/5 <= x <= 2/5, 0 < y <= 10}, {x, y}]
{12/5, {x -> 2/5, y -> 10}}

David Park
djmp at

From: Caspar von Seckendorff [mailto:seckendorff at]
To: mathgroup at


I'd like to do constrained optimization with Mathematica 5.1 on a
function that is defined piecewise. Unfortunately Maximize[] does not
work  as I expected. A short & simple example to illustrate:

f[x_,y_]:= (x-x^2) y
Maximize[{f[x, y], 1/5 <= x <= 2/5, y > 0}, x]

As a result I get:
"The objective function (x-x^2) y contains a nonconstant expression y
independent of variables {x}."

Obviously for this Maximization, knowing that y > 0 I can do the
following to get the desired value for x:

Maximize[{x-x^2, 1/5 <= x <= 2/5}, x]
Out[]= {6/25, {x -> 2/5}}

Is there a way to achieve this without manual intervention? The reason
is, that the functions I want to Maximize are defined Piecewise with
several constraints...



  • Prev by Date: Re: Constrained Optimization
  • Next by Date: Re: simple set operations
  • Previous by thread: Re: Constrained Optimization
  • Next by thread: Re: Constrained Optimization