Re: Problem with element and Maximize
- To: mathgroup at smc.vnet.net
- Subject: [mg82846] Re: Problem with element and Maximize
- From: Uncle Paul <paul at desinc.com>
- Date: Thu, 1 Nov 2007 05:14:08 -0500 (EST)
- References: <4209462.1193744482571.JavaMail.root@m35> <fg9pgk$mtl$1@smc.vnet.net>
>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}}
>
>10.92
>
>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
one.
Paul