MathGroup Archive 2001

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

Search the Archive

simplify with If's (with web interface)

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

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

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

should simplify to

If[a,x,z]

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):
http://ai.eecs.umich.edu/people/dreeves/simplify.html

Thanks,
Daniel

--    --    --    --    --    --    --    --    --    --    --    -- 
Daniel Reeves               http://ai.eecs.umich.edu/people/dreeves/




  • 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)