       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:=
{Reduce[0 <= Log[y], y], Reduce[0 <= Log[x] <= 2, x],
Reduce[2 <= Log[z] + 1, z]}

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

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

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

In:=
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:=
testFunc[]

Out=
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!