       Re: FindInstance with all positive numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg122510] Re: FindInstance with all positive numbers
• From: "Dr. Wolfgang Hintze" <weh at snafu.de>
• Date: Sun, 30 Oct 2011 04:24:25 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <j8gnrm\$5hp\$1@smc.vnet.net>

```Even if this is not very elegant you could use variables a,
...,a[n].
Then you can implment the positivity condition very easily

n = 2;
la = (a[#1] & ) /@ Range[n]
eq = Plus @@ la == 5
cond = And @@ (a[#1] > 0 & ) /@ Range[n]

FindInstance[{eq, cond}, la, Rationals]
FindInstance[{eq, cond}, la, Reals]
FindInstance[{eq, cond}, la, Integers]
Out=
{a, a}
Out=
a + a == 5
Out=
a > 0 && a > 0
Out=
{{a -> 5/2, a -> 5/2}}
Out=
{{a -> 5/2, a -> 5/2}}
Out=
{{a -> 4, a -> 1}}

--- Wolfgang

"Arthur Grabovsky" <shukrri at gmail.com> schrieb im Newsbeitrag
news:j8gnrm\$5hp\$1 at smc.vnet.net...
> Hi,
>
> To ensure FindInstance[] returns all positive numbers I would do:
>
> FindInstance[a+b=5&&a>0&&b>0,{a,b}];
>
> However I need to do the same but without having to list all
> individual variables. The reason is that I will be iterating through
> lists with a large, variable number of elements so writing out
> a>0&&b>0 all the way until z>0 is impractical.
>
> Thanks.
>

```

• Prev by Date: Defining a Discrete Probability Distribution using ProbabilityDistribution
• Next by Date: Re: How to combine 2 list
• Previous by thread: Re: FindInstance with all positive numbers
• Next by thread: How to combine 2 list