MathGroup Archive 2006

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

Search the Archive

Re: PiecewiseExpand bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68501] Re: PiecewiseExpand bug?
  • From: ab_def at prontomail.com
  • Date: Tue, 8 Aug 2006 06:28:38 -0400 (EDT)
  • References: <eb45vn$n7p$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mark Fisher wrote:
> This produces what I expect:
>
> Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}] /.
> 	{x[1] -> 0, x[2] -> 1, x[3] -> 1}
>
> But this does not:
>
> PiecewiseExpand[Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}]] /.
> 	{x[1] -> 0, x[2] -> 1, x[3] -> 1}
>
> It appears PiecewiseExpand does something it shouldn't here. Any thoughts?
>
> --Mark.

Yes, it's a bug. A simpler example:

In[1]:= f[x_] := Piecewise[{{1, x == 1}, {2, x == 2}}]

In[2]:= Reduce[f[x]*f[y]*f[z] != PiecewiseExpand[f[x]*f[y]*f[z]]]

Out[2]= z == 2 && y == 2 && x == 1

That is, the result of PiecewiseExpand gives a wrong value at one
point. It seems that the problem doesn't arise if we use a non-zero
default value:

In[3]:= <<statistics`

In[4]:= Product[PDF[BernoulliDistribution[p], x[i]], {i, 3}] /.
      HoldPattern[Piecewise[L_] | Piecewise[L_, 0]] :>
        Piecewise[L, zero] //
    PiecewiseExpand[#] /. zero -> 0& //
  # /. {x[1] -> 0, x[2] -> 1, x[3] -> 1}&

Out[4]= (-(-1 + p))*p^2

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: MemberQ
  • Next by Date: How to get the output of Minimize function in x = a format
  • Previous by thread: Re: PiecewiseExpand bug?
  • Next by thread: Minimize