MathGroup Archive 2007

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

Search the Archive

Re: Problem with element and Maximize

>Don't round the real-valued solution; it won't always get you the best  
>integer solution.
>But this should work:
>data = {{0, 0}, {10, 10}, {20, 0}, {30, 10}};
>eq = Fit[data, {1, x, x^2, x^3}, x]
>proxy = Rationalize[eq, 10^-15]
>Maximize[{proxy, x \[Element] Integers, x <= 20}, x]
>eq /. Last@%
>1.96128*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3
>1/509872338168900 + (10 x)/3 - (3 x^2)/10 + x^3/150
>{5567805932804389/509872338168900, {x -> 7}}
>Without the upper bound the function has no maximum and, with approximate  
>coefficients, Maximize can't use efficient integer optimization methods.

I don't disagree this works.  There are two issues with this, though. 

The unbounded answer of 5 indicates it is trying for local maxima,
something I would expect.

The second issue is I would expect one of three possibilities.  If I
ask a mathemetician, I would expect either a local maxima or
+infinity.  If I ask software, I would expect local maxima, +infinity
or a complaint.  An incorrect answer without complaint is confusing.

Cool technique with Rationalize[] though.  I'll have to remember that


  • Prev by Date: Re: Issue with Locator's crosshairs object
  • Next by Date: Re: Simplifying polynomial and rounding problems
  • Previous by thread: Re: FindRoot and Bose-Einstein distribution
  • Next by thread: Re: Re: Problem with element and Maximize