# How to set constraints for QuadraticOptimization

**URL:** <https://community.wolfram.com/t/how-to-set-constraints-for-quadraticoptimization/26370>\
**Category:** Questions\
**Tags:** optimization\
**Created:** [January 21, 2026, 2:48pm UTC](https://community.wolfram.com/t/how-to-set-constraints-for-quadraticoptimization/26370 "2026-01-21T14:48:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shg](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@shg](https://community.wolfram.com/u/shg)\
**Post date:** [January 21, 2026, 2:48pm UTC](https://community.wolfram.com/t/how-to-set-constraints-for-quadraticoptimization/26370/1 "2026-01-21T14:48:17Z")

</div>

Hi, I am trying to minimize a function with 9 variables using - `QuadraticOptimization[{q,c},{a,b}]`  
Here q is a 9X9 matrix whereas c is a 9X1 matrix.

{q, c} part is working fine when I use `{a, b} = {{}, {}}`, which means there are no constraints over the values of 9 variables. I get the o/p in this case.

However, I want to put a constraint that these nine variables have only positive values. How to put this constrain in form of {a, b}. According to the definition of a and b, ({a, b} is equivalent to ax+b\>= 0), I should have a =1 and b = 0 for each of the nine variables. So I tried {{1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}}. However it did not work.

Will appreciate any suggestions. Thanks

---

<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:** [January 21, 2026, 3:55pm UTC](https://community.wolfram.com/t/how-to-set-constraints-for-quadraticoptimization/26370/2 "2026-01-21T15:55:43Z")

</div>

The `ax` term in `ax+b>= 0` is matrix multiplication, not scalar. I would try

```
a = IdentityMatrix[9];
b = Table[0, 9];
a . Array[x, 9] + b

```
