# Solve for a linear system with equalities and ineqaulities

**URL:** <https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957>\
**Category:** Questions\
**Tags:** algebra, equation-solving, numerical-computation\
**Created:** [October 12, 2023, 6:09pm UTC](https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957 "2023-10-12T18:09:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xzhou](https://avatars.discourse-cdn.com/v4/letter/x/3be4f8/32.png) [@xzhou](https://community.wolfram.com/u/xzhou)\
**Post date:** [October 12, 2023, 6:09pm UTC](https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957/1 "2023-10-12T18:09:20Z")

</div>

Hi there,

Need help on solving for x5 in the following system:  
x2 == 3 (5-x5) && x3 == 2 (3-x5) && x2\>=0 && x3 \>=0 && x5 \>=0

I expect to have something like x5 \<= 3, but Reduce gives the following solution:  
(x2==6 && x3==0 && x5 ==3) || …

Any suggestions on how to let MMA give x5 \<= 3 as the solution?

Many thanks!  
Xiangyang

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [October 13, 2023, 5:54am UTC](https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957/2 "2023-10-13T05:54:18Z")

</div>

Simplify[  
Reduce[x2==3(5-x5)&&x2\>=0&&x5\>=0]&&  
Reduce[x3==2(3-x5)&&x3\>=0&&x5\>=0],  
x2==3(5-x5)&&x2\>=0&&x3==2(3-x5)&&x3\>=0]

returns

```
0<=x5<=3

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [October 13, 2023, 6:45am UTC](https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957/3 "2023-10-13T06:45:38Z")

</div>

Another way:

```
Reduce[Exists[{x2, x3},
  x2 == 3 (5 - x5) && x3 == 2 (3 - x5) &&
   x2 >= 0 && x3 >= 0 && x5 >= 0]]

```

---

<div class="post-metadata">

**Author:** ![xzhou](https://avatars.discourse-cdn.com/v4/letter/x/3be4f8/32.png) [@xzhou](https://community.wolfram.com/u/xzhou)\
**Post date:** [October 17, 2023, 2:27am UTC](https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957/4 "2023-10-17T02:27:43Z")

</div>

Solved the problem. Many thanks!

---

<div class="post-metadata">

**Author:** ![xzhou](https://avatars.discourse-cdn.com/v4/letter/x/3be4f8/32.png) [@xzhou](https://community.wolfram.com/u/xzhou)\
**Post date:** [October 17, 2023, 2:28am UTC](https://community.wolfram.com/t/solve-for-a-linear-system-with-equalities-and-ineqaulities/22957/5 "2023-10-17T02:28:03Z")

</div>

Thanks for the help!
