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
Today the same code outputs a Maximize failure and crashes the kernel:
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@%
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3
1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150
Maximize[{1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150, x \[Element] Integers, x <= 20}, x]
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3 /. x
Ditto with this code (moving Integers to the third argument):
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 <= 20}, x, Integers]
eq /. Last@%
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3
1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150
Maximize[{1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150, x <= 20}, x, Integers]
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3 /. Integers
Odder yet, the kernel doesn't crash in Fit, Rationalize, or even Maximize,
but rather, in ReplaceAll (which does nothing), yet AFTER the FE outputs a
result:
data = {{0, 0}, {10, 10}, {20, 0}, {30, 10}};
eq = Fit[data, {1, x, x^2, x^3}, x]
proxy = Rationalize[eq, 10^-15]
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3
1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150
Maximize[{proxy, x <= 20}, x, Integers]
Maximize[{1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150, x <= 20}, x, Integers]
eq /. Last@%
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3 /. Integers
Same here, without LessEqual:
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, Integers]
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3
1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150
Maximize[1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150, x, Integers]
eq /. Last@%
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3 /. Integers
And same here, after outputting a correct result:
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]
2.63678*10^-15 + 3.33333 x - 0.3 x^2 + 0.00666667 x^3
1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150
{\[Infinity], {x -> \[Infinity]}}
{$Version, $ReleaseNumber}
{"7.0 for Mac OS X x86 (64-bit) (February 19, 2009)", 1}
What's going on????
Bobby
I don't get a crash, and my older Mathematica system doesn't handle
this code any better than the new one. Both 5.2 and 7.01 report the
same ReplaceAll warning and the ouput is the same apart from a
difference in the very small constant term.
Cheers -- Sjoerd
> Odder yet, the kernel doesn't crash in Fit, Rationalize, or even Maximize=
,
> but rather, in ReplaceAll (which does nothing), yet AFTER the FE outputs =
DrMajorBob wrote:
>
> eq /. Last@%
>
>
>
> {5567805932804389/509872338168900, {x -> 7}}
>
> 10.92
>
>
> eq /. Last@%
>
>
> 3 x^2)/10 + x^3/150
>
>
>
>
> eq /. Last@%
>
>
> 3 x^2)/10 + x^3/150
>
>
>
> result:
>
>
>
> 3 x^2)/10 + x^3/150
>
>
>
> eq /. Last@%
>
>
> Same here, without LessEqual:
>
> Maximize[proxy, x, Integers]
>
>
> 3 x^2)/10 + x^3/150
>
>
> eq /. Last@%
>
>
>
> Maximize[proxy, x]
>
>
> 3 x^2)/10 + x^3/150
>
>
> {$Version, $ReleaseNumber}
>
>
> What's going on????
>
> Bobby
>
Hi Bobby,
with version 7.0.1 on Vista, the following does not evaluate:
Maximize[{proxy, x \[Element] Integers, x <= 20}, x]
The parser seems to have problems with: x \[Element] Integers
It seems to work if one put this condition in an "Assuming":
Assuming[x \[Element] Integers, Maximize[{proxy, x <= 20}, x]]
Daniel
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 <= 20}, x, Integers]
Maximize[{1/379250494936462 + (105718301111983 x)/31715490333595 - (
3 x^2)/10 + x^3/150, x <= 20}, x, Integers]
Bobby
On Tue, 24 Nov 2009 03:38:52 -0600, dh <d...@metrohm.com> wrote:
> Hi Bobby,
> with version 7.0.1 on Vista, the following does not evaluate:
> Maximize[{proxy, x \[Element] Integers, x <= 20}, x]
> The parser seems to have problems with: x \[Element] Integers
> It seems to work if one put this condition in an "Assuming":
> Assuming[x \[Element] Integers, Maximize[{proxy, x <= 20}, x]]
>
> Daniel
>
>
>