MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindInstance with all positive numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122494] Re: FindInstance with all positive numbers
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sun, 30 Oct 2011 04:21:32 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110291113.HAA05435@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

variables = Table[Unique[\[Alpha]], {i, 10}];
variables /.
  FindInstance[Total@variables == 5 && And @@ Thread[variables > 0],
   variables]

{{5/512, 5/2, 5/4, 5/8, 5/16, 5/32, 5/64, 5/128, 5/256, 5/512}}

or

variables = Array[Unique[\[Alpha]] &, {10}];
variables /.
  FindInstance[Total@variables == 5 && And @@ Thread[variables > 0],
   variables]

{{5/512, 5/2, 5/4, 5/8, 5/16, 5/32, 5/64, 5/128, 5/256, 5/512}}

Bobby

On Sat, 29 Oct 2011 06:13:34 -0500, Arthur Grabovsky <shukrri at gmail.com>  
wrote:

> 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.
>


-- 
DrMajorBob at yahoo.com



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