Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.8K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Max length of a function during Maximize

Posted 5 years ago

Hi, I'm trying to solve a global constrained non-linear optimization problem with Wolfram but it's not working as expected for me. I tried with a simplified version of my problem and I reached a point when it fails to correctly recognize the type of problem. For example if I paste in the api explorer here https://products.wolframalpha.com/api/explorer/ the following code it works properly:

NMaximize[{3.6027769090403445*1e-52*a^3 + 9.73306257869222*1e-52*a^2*b + (-3.1793546987662064)*1e-67*a^2 + 6.968194393839056*1e-52*a*b^2, a >= 0 && b >=0 && a + b == 290015693412189845814109}, {a, b}]

If instead I add just one monomial to the function to maximize, 5.7587424928741081e-75a*b in this case, it fails to recognize the problem correctly as it's suggesting me "NMaximize 3.6027769090403445"

NMaximize[{3.6027769090403445*1e-52*a^3 + 9.73306257869222*1e-52*a^2*b + (-3.1793546987662064)*1e-67*a^2 + 6.968194393839056*1e-52*a*b^2 + 5.758742492874108*1e-75*a*b, a >= 0 && b >=0 && a + b == 290015693412189845814109}, {a, b}]

Are there limitations on the input size?

Thanks in advance.

POSTED BY: W B
4 Replies
Anonymous User
Anonymous User
Posted 5 years ago

I tried your function and numerical precision and accuracy limits were exceeded. You can alleviate this by raising the same (see Help) or using base numbers with higher accuracy and precision (more digits) or by using arbitrary precision numbers. (it's suggested you always use arbitrary precision at all times unless limited accuracy and precision, including error of calculations, are to be calculated intentionally). Next note I zero'ed some of the last digits of "a+b". This is due to calculation errors that Mathematica tracks on each +, -, /, *.

In[404]:= NMaximize[{3.6027769090403445 10^(-52) a^3 + 
   9.73306257869222 10^(-52) a^2 b + -3.1793546987662064 10^(-67) a^2 \
+ 6.968194393839056 10^(-52) a b^2, 
  a >= 0 && b >= 0 && a + b == 290015693412189000000000}, {a, b}]

Out[404]= {8.78824*10^18, {a -> 2.90016*10^23, b -> 0.}}

In[401]:= Maximize[{Rationalize[3.6027769090403445 10^(-52), 
     10^(-52)] a^3 + 
   Rationalize[9.73306257869222 10^(-52), 10^(-52)] a^2 b + 
   Rationalize[-3.1793546987662064 10^(-67), 10^(-67)] a^2 + 
   Rationalize[6.968194393839056 10^(-52), 10^(-52)] a b^2, 
  a >= 0 && b >= 0 && a + b == 290015693412189845814109}, {a, b}]

Out[401]= \
{415916158542085055402727940040315199561430548561835112571162290342123\
8795019140734549704991222017851010872571220634013/
  47326449583022447216549007278772095603881176748731854250575980000411\
7209146543199805755858639388672, {a -> 290015693412189845814109, 
  b -> 0}}

I hope that helps you search where in Help you can look to resolve your question. And yes the N in NMaximize does mean calculations will have a limited width, ie, FindRoot[x^2 - 2, {x, 1}, WorkingPrecision -> 60]. Ultimately when you use "numeric approximation" functions that are built to take advantage of built-in math in your CPU, they will be limited and fail, and to get around this limit you must forego math-chip acceleration. The subject of rounding error correctly during programs is an involved one - it's suggested you use arbitrary precision where possible except when printing final results in decimal digits.

POSTED BY: Anonymous User
Posted 5 years ago
POSTED BY: W B

What specifically is meant by "input not interpreted correctly"? Is this being done in Mathematica, or Wolfram|Alpha?

POSTED BY: Daniel Lichtblau
Posted 5 years ago
POSTED BY: W B
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard