Re: gives

*To*: mathgroup at smc.vnet.net*Subject*: [mg125910] Re: gives*From*: Bob Hanlon <hanlonr357 at gmail.com>*Date*: Fri, 6 Apr 2012 06:00:52 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <201204050952.FAA13197@smc.vnet.net>

ClearAll[PDD, try, t, z, aa]; PDD[a_?NumericQ, idx_] := 0; t = aa PDD[z, d]; try[expr_] := Replace[expr, aa_. PDD[bb_, cc_] :> -bb PDD[aa, cc]]; Simplify[t, TransformationFunctions :> {try}] 0 The default value for aa in aa_. PDD[bb_, cc_] is one. Consequently, PDD[z, d] by itself matches the LHS of the rule and becomes -z PDD[1, d] which evaluates to zero. Note the behavior if the default is removed: try[expr_] := Replace[expr, aa_ PDD[bb_, cc_] :> -bb PDD[aa, cc]]; Simplify[t, TransformationFunctions :> {try}] aa PDD[z, d] Bob Hanlon On Thu, Apr 5, 2012 at 5:52 AM, Yi Wang <tririverwangyi at gmail.com> wrote: > Hi, all, > > I met a problem when using the TransformationFunctions option in Simplify: > > ClearAll[PDD,try,t,z,aa]; > PDD[a_?NumericQ, idx_] := 0; > t = aa PDD[z, d]; > try[expr_] := Replace[expr, aa_. PDD[bb_, cc_] :> -bb PDD[aa, cc]]; > Simplify[t, TransformationFunctions :> {try}] > > I expect Simplify to do nothing, because the replace rule in try[] does not make the function simpler in this special case. However, Simplify[...] returns 0. > > If I delete the line " PDD[a_?NumericQ, idx_] := 0; ", Simplify will give the correct result. However, z (or N[z]) is not a number thus it seems the above line shouldn't matter. > > I also tried several other tests. I found a_?NumberQ, a_?IntegerQ both have the above problem, while a_ListQ has the desired behaviour. >

**References**:**Specify TransformationFunctions in Simplify[] gives wrong result***From:*Yi Wang <tririverwangyi@gmail.com>