MathGroup Archive 2003

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

Search the Archive

Simplify a module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39450] Simplify a module
  • From: "flip" <flip_alpha at safebunch.com>
  • Date: Sun, 16 Feb 2003 06:13:46 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi All,

Can someone recommend a simplification to this module (just a bunch of if
checks).

It was specified to be done that way (and I know how to sove the problem
using PowerMod in one step, so please bear with me here).

Thanks, Flip

(* to email me remove "_alpha" *)

Anyway, here goes.

dcalc[ein_] := Module[{e = ein, a1 = 0, a2 = 0, a3 = 0},
    {T1, M1, T2, M2, T3, M3} = {2, 392, 3, 147, 47, 24};
    If[Mod[e, 3] == 1, a1 = 1]; If[Mod[e, 3] == 2, a1 = 2];
    If[Mod[e, 8] == 1, a2 = 1];
    If[Mod[e, 8] == 3, a2 = 3]; If[Mod[e, 8] == 5, a2 = 5];
    If[Mod[e, 8] == 7, a2 = 7];
    If[Mod[e, 49] == 1, a3 = 1]; If[Mod[e, 49] == 2, a3 = 25];
    If[Mod[e, 49] == 3, a3 = 33]; If[Mod[e, 49] == 4, a3 = 37];
    If[Mod[e, 49] == 5, a3 = 10]; If[Mod[e, 49] == 6, a3 = 41];
    If[Mod[e, 49] == 8, a3 = 43]; If[Mod[e, 49] == 9, a3 = 11];
    If[Mod[e, 49] == 10, a3 = 5]; If[Mod[e, 49] == 11, a3 = 9];
    If[Mod[e, 49] == 12, a3 = 45]; If[Mod[e, 49] == 13, a3 = 34];
    If[Mod[e, 49] == 15, a3 = 36]; If[Mod[e, 49] == 16, a3 = 46];
    If[Mod[e, 49] == 17, a3 = 26]; If[Mod[e, 49] == 18, a3 = 30];
    If[Mod[e, 49] == 19, a3 = 31]; If[Mod[e, 49] == 20, a3 = 27];
    If[Mod[e, 49] == 22, a3 = 29]; If[Mod[e, 49] == 23, a3 = 32];
    If[Mod[e, 49] == 24, a3 = 47]; If[Mod[e, 49] == 25, a3 = 2];
    If[Mod[e, 49] == 26, a3 = 17]; If[Mod[e, 49] == 27, a3 = 20];
    If[Mod[e, 49] == 29, a3 = 22]; If[Mod[e, 49] == 30, a3 = 18];
    If[Mod[e, 49] == 31, a3 = 19]; If[Mod[e, 49] == 32, a3 = 23];
    If[Mod[e, 49] == 33, a3 = 3]; If[Mod[e, 49] == 34, a3 = 13];
    If[Mod[e, 49] == 36, a3 = 15]; If[Mod[e, 49] == 37, a3 = 4];
    If[Mod[e, 49] == 38, a3 = 40]; If[Mod[e, 49] == 39, a3 = 44];
    If[Mod[e, 49] == 40, a3 = 38]; If[Mod[e, 49] == 41, a3 = 6];
    If[Mod[e, 49] == 43, a3 = 8]; If[Mod[e, 49] == 44, a3 = 39];
    If[Mod[e, 49] == 45, a3 = 12]; If[Mod[e, 49] == 46, a3 = 16];
    If[Mod[e, 49] == 47, a3 = 24]; If[Mod[e, 49] == 48, a3 = 48];
    Return[Mod[a1*T1*M1 + a2*T2*M2 + a3*T3*M3, 1176]]]









  • Prev by Date: Re: AbsoluteThickness - a feature or a problem?
  • Next by Date: Re: Problem with If statement in a Do or a While loop
  • Previous by thread: Re: ParametricPlot - a feature or a bug?
  • Next by thread: Re: Simplify a module