Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 Non linear constrained interger Optimization (you can check out this one too!)

share
3  
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. –  Corey Kelly Jun 17 '13 at 15:14
    
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 –  Michio kaku Jun 17 '13 at 16:08
    
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. –  Corey Kelly Jun 17 '13 at 16:13
    
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. –  Corey Kelly Jun 17 '13 at 16:27
    
@CoreyKelly i have updated the problem as requested. –  Michio kaku Jun 17 '13 at 16:58

1 Answer 1

up vote 0 down vote accepted

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}}

share
    
thanks it helped –  Michio kaku Jul 19 '13 at 10:59
    
@Michiokaku glad I could help :) –  Jacob Akkerboom Jul 19 '13 at 18:01

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .