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}]
I hope the results will be rationalize
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.
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}}