MathGroup Archive 2001

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

Search the Archive

simplify with If's (with web interface)

  • To: mathgroup at
  • Subject: [mg28873] simplify with If's (with web interface)
  • From: Daniel Reeves <dreeves at>
  • Date: Wed, 16 May 2001 03:28:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

I'm looking for a way to simplify nested conditionals, like

If[a, If[a, x, y], z]

should simplify to


I wrote some really awful code to do this:

simplifyAll[x_] := FullSimplify[Evaluate //@ x]

simpIf[x_, y_, z_] := Module[{sx = FullSimplify[x]},
  If[sx, Evaluate[FullSimplify[y, sx]],
         Evaluate[FullSimplify[z, Not[sx]]]]]

simplifyWithIfsSub[x_] :=
  FixedPoint[simplifyAll, FixedPoint[simplifyAll, x] /. If->simpIf]

simplifyWithIfs[x_] := FixedPoint[simplifyWithIfsSub, x]

I'm thinking someone has probably already done this so I don't want to
spend too much time working on the approach above.

PS, I have a web interface to my simplifier (which accepts input in either
mathematica or lisp syntax):


--    --    --    --    --    --    --    --    --    --    --    -- 
Daniel Reeves     

  • Prev by Date: Re: Creating graph with only a view data points
  • Next by Date: Re: Decimal math bug?
  • Previous by thread: "Re: don't understand #"
  • Next by thread: Re: simplify with If's (with web interface)