Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: mg67144: 3rd try!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67192] Re: mg67144: 3rd try!
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 11 Jun 2006 23:07:56 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <e6gdj8$nco$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

jackgoldberg at comcast.net wrote:
> Hi again,
> 
> I am writing this after sending in a correction to the referenced post.  The correction is not yet posted, so if you will forgive me, here is the up-to-date version of my questions.
> 
> I have constructed a Module whose last line is 
> 
> L5=Apply[List, "a collection of equalities and inequalities such as the one given below"]
> 
> This Module returns something like this,
> 
> {x==y, -3<=u<=1,t==5}
> 
> If I set, bb = {x==y, -3<=u<=1,t==5} (outside the Module) and then use Replace all, say,
> 
> bb/.{a_,q_,b_}->-1,
> 
> I get what I expect:   {x==y, -1, t==5}.  This leads me to the reasonable(?) conclusion that I could put this last step inside the Module.  So, my new Module looks like this (at the end)
> 
> L5=Apply[List, "..."];           (The quotes is to save space.  An expression is there.)
> L6=L5/.{a_,q_,b_}->-1  ]        (and the Module ends.)
> 
> When the new version is run, the /. has no effect.  Why?  So it appears that the replacement rule which works outside the Module fails in the Module.  To add to my confusion, if  L6 is given this way,
> 
> L6=Position[L5,LessEqual[-3,u,1]]  ]
> 
> The Module returns  {}.
> 
> Help is needed.
> 
> Jack
> 
Hi Jack,

Not sure what happened on your system, but the following expression work 
correctly both outside and inside a module.

In[1]:=
{Reduce[0 <= Log[y], y], Reduce[0 <= Log[x] <= 2, x],
   Reduce[2 <= Log[z] + 1, z]}

Out[1]=
                     2
{y >= 1, 1 <= x <= E , z >= E}

In[2]:=
{Reduce[0 <= Log[y], y], Reduce[0 <= Log[x] <= 2, x],
    Reduce[2 <= Log[z] + 1, z]} /.
   Inequality[a_, __, b_] -> (a + b)/2

Out[2]=
          1       2
{y >= 1, - (1 + E ), z >= E}
          2

In[3]:=
testFunc[] := Module[{}, {Reduce[0 <= Log[y], y],
      Reduce[0 <= Log[x] <= 2, x],
      Reduce[2 <= Log[z] + 1, z]} /.
     Inequality[a_, __, b_] -> (a + b)/2]

In[4]:=
testFunc[]

Out[4]=
          1       2
{y >= 1, - (1 + E ), z >= E}
          2

Regards,
/Jean-Marc


  • Prev by Date: Some questions regarding loops and lists.
  • Next by Date: Re: structure array equivalent in Mathematica
  • Previous by thread: Re: mg67144: 3rd try!
  • Next by thread: ? about Rule (rewritten)