Can anyone simplify this?

*To*: mathgroup at smc.vnet.net*Subject*: [mg36461] Can anyone simplify this?*From*: Moranresearch at aol.com*Date*: Sat, 7 Sep 2002 02:54:53 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

I have substituted the letters SS, CC, X, Y and Z1 and Z2 for some complicated expressions just to illustrate the form of the function. This function works and all the conditions are necessary but I am sure a more elegant programming solution perhaps using While could be found. Any suggestions to tighten this up? Thank you. f[{Sa_, Ca_, Aa_, Sb_, Cb_, Ab_, a_, b_}] := {If[Aa == Ab, a Sa + b Sb, If[Ca == 0 || Cb == 0, a Sa + b Sb, SS]], If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0, "Nil", If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, "Nil", If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, "Nil", If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]}