Message Boards Message Boards

How to merge Limit in Solve?

Posted 1 year ago

Hello, I am trying to solve several equations in Mathematica.

Rationalize@
 Solve[{-101.81 a - 47.62*b - 36.42*c - 32.51*d == -61.91, -12.48*a - 
     7.58*b - 6.11*c - 5.63*d == -8.91, a + b + c + d -> 1, a >= 0, 
   b >= 0, c >= 0, d >= 0}, {a, b, c, d}]
  1. I hope the results will be rationalize
  2. I know if a+b+c+d==1, there will be no results. So I hope to find results about making a+b+c+d as equal as 1 as possible and I add a + b + c + d -> 1 in. I know it is not right code.

How should I do to solve this?

POSTED BY: Zhenyu Zeng
4 Replies

You could minimize the distance between a + b + c + d and 1:

In[1]:= constr = Rationalize[And@@{-101.81 a - 47.62*b - 36.42*c - 32.51*d == -61.91,                                                                           
     -12.48*a - 7.58*b - 6.11*c - 5.63*d == -8.91, a + b + c + d == 1 + eps,    
     a >= 0, b >= 0, c >= 0, d >= 0}];                                          

In[2]:= Minimize[{Abs[eps], constr}, {eps, a, b, c, d}]//InputForm

Out[2]//InputForm= 
{20517/1774222, {eps -> 20517/1774222, a -> 224918/887111, 
  b -> 1344903/1774222, c -> 0, d -> 0}}
POSTED BY: Adam Strzebonski
Posted 1 year ago

Thanks for your reply. You answer helps me a lot.

POSTED BY: Zhenyu Zeng

Reduce and Solve gives:

eq = Rationalize[{-101.81 a - 47.62*b - 36.42*c - 
     32.51*d == -61.91, -12.48*a - 7.58*b - 6.11*c - 5.63*d == -8.91, 
   a + b + c + d == 1}, 0]

 (*{-((10181 a)/100) - (2381 b)/50 - (1821 c)/50 - (3251 d)/100 == -(
    6191/100), -((312 a)/25) - (379 b)/50 - (611 c)/100 - (563 d)/
    100 == -(891/100), a + b + c + d == 1}*)

Reduce[First@eq && a >= 0 && b >= 0 && c >= 0 && d >= 0, {a, b, c, d}]
(*0 <= a <= 6191/
  10181 && ((0 <= b < (6191 - 10181 a)/4762 && 
     0 <= c <= (6191 - 10181 a - 4762 b)/3642) || (b == (
      6191 - 10181 a)/4762 && c == 0)) && 
 d == (6191 - 10181 a - 4762 b - 3642 c)/3251*)

Solve[First@eq && a >= 0 && b >= 0 && c >= 0 && d >= 0, {a, b, c, d}, MaxExtraConditions -> All]

(*{{a -> ConditionalExpression[(6191 - 4762*b - 3642*c - 3251*d)/10181, 
    Inequality[0, LessEqual, b, LessEqual, 6191/4762] && c >= 0 && -6191 + 4762*b + 3642*c < 0 && d >= 0 && 
     -6191 + 4762*b + 3642*c + 3251*d <= 0]}, {a -> ConditionalExpression[0, 0 <= b <= 6191/4762], 
  c -> ConditionalExpression[(6191 - 4762*b)/3642, 0 <= b <= 6191/4762], 
  d -> ConditionalExpression[0, 0 <= b <= 6191/4762]}}*)

Looks like solution exist.

POSTED BY: Mariusz Iwaniuk
Posted 1 year ago

Hello, Thanks for your reply. I see that you didn't use the second part and the third part of eq. Is it right?

POSTED BY: Zhenyu Zeng
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract