1
$\begingroup$

How can I define working precision for each variable individually

for example:

Maximize[x y< 100, {x, y}]

where the working precisions for x and y should be 2 and 7 respectively.

Say x is some real life quantity that is ONLY available to 2 decimal places and we need y to be as precise as possible (say 7 decimal places) regardless of the precision of xy. How can I do this in Mathematica?

here is exact problem

   Maximize  hsum + isum + jsum + ksum + lsum + msum + nsum + osum

constraints are:

   0 < hsum,isum,jsum,ksum,lsum,msum,nsum < 10000
  -5000 < osum < 0

   a*x1 + b*x2 + d*x4 - h*(x1 + x2 + x4) = hsum
   a*x1 + b*x2 + d*x4 - i*(x1 + x2 + x4) = isum
   a*x1 + b*x2 + e*x5 - j*(x1 + x2 + x5) = jsum
   a*x1 + b*x2 + e*x5 - k*(x1 + x2 + x5) = ksum
   a*x1 + c*x3 + f*x6 - l*(x1 + x3 + x6) = lsum
   a*x1 + c*x3 + f*x6 - m*(x1 + x3 + x6) = msum
   a*x1 + c*x3 + g*x7 - n*(x1 + x3 + x7) = nsum 
   a*x1 + c*x3 + g*x7 - o*(x1 + x3 + x7) = osum      

X1,X2,X3....X7 are integers

a=100

b = (a + u1) && c = (a - u2) && d = (b + u3) && e = (b - u4) && 
f = (c + u5) && g = (c - u6) && h = (d + u7) && i = (d - u8) && 
j = (e + u9) && k = (e - u10) && l = (f + u11) && M = (f - u12) &&
n = (g + u13) && o = (g - u14) 


0.1 <= u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14 <= 3

in the above problem a is 100 rest of the variables b,c,d,e,f,g,h,i,j,k,l,m,n,o can be derived by adding or subtracting u1,u2,u3....u14 now i need to define that value of u must be upto 2 decimal places.

Also here is the link for the same https://mathematica.stackexchange.com/questions/27105/non-linear-constrained-interger-optimization (you can check out this one too!)

$\endgroup$
  • 3
    $\begingroup$ Since the answer depends on combinations (products, sums) of x and y, you can't define their precisions separately. If the precision of x is 2, then all internal precision will be 2. $\endgroup$ – Corey Kelly Jun 17 '13 at 15:14
  • $\begingroup$ Say x is some real life quantity that is ONLY available upto 2 decimal places and we need y to be precise as much as possible,it doesn't no matter what is the precision result of xy $\endgroup$ – Michio kaku Jun 17 '13 at 16:08
  • $\begingroup$ You can define the input and output precisions of x and y easily. Working Precision determines how many decimal places are maintained for internal computation. If you want y to have a precision of 7, then use WorkingPrecision->7. Your question is one of error propagation, not a Mathematica issue. $\endgroup$ – Corey Kelly Jun 17 '13 at 16:13
  • $\begingroup$ It might be helpful to see the actual problem you're working on. In the example you give, if x is known, then you can't Maximize with respect to it, and the inequality lets you directly find y. $\endgroup$ – Corey Kelly Jun 17 '13 at 16:27
  • $\begingroup$ @CoreyKelly i have updated the problem as requested. $\endgroup$ – Michio kaku Jun 17 '13 at 16:58
0
$\begingroup$

How about this?

N[{#, {x/10^2, y/10^7} /. #2} & @@ 
  Maximize[x/10^2* y/10^7, x/10^2* y/10^7 < 100, {x, y}, 
   Integers], 12]

{99.9999999990, {-0.0100000000000, -9999.99999990}}

$\endgroup$
  • $\begingroup$ @Michiokaku glad I could help :) $\endgroup$ – Jacob Akkerboom Jul 19 '13 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.