Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7935
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How to easily set up all coefficients to be positive in Solving an integer equation? |
| Date | 2012-01-17 08:50 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jf3coq$npg$1@smc.vnet.net> (permalink) |
n = 5;
var = Array[x, n];
coef = RandomInteger[{-10, 10}, n];
Solve[Flatten[{coef.var == 0, Thread[var > 0]}], var, Integers]
Bob Hanlon
On Mon, Jan 16, 2012 at 5:11 PM, Rex <aoirex@gmail.com> wrote:
> Given a vector `A==[a_1, a_2, a_3,...,a_n]`, where a_i are integers,
> now
> solving an equation
> `=E2=88=91a_i * x_i==0` with all x_i>==0, and x_i to be integers.
>
> We can write some code like this
> `Solve[A . Table[x[i], {i, n}] == 0 && Table[x[i] > 0, {i, n}],
> Integers]`
>
> But the conditions above `Table[x[i] > 0` is not rightly coded. That
> should be
> `x[1]>0 && x[2]>0 && x[3]>0 &&...x[n]>0`
> Is there any easy way to write such code?
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: How to easily set up all coefficients to be positive in Solving an integer equation? Bob Hanlon <hanlonr357@gmail.com> - 2012-01-17 08:50 +0000
csiph-web