FactorType[f_, p_] := 
      Module[{degs}, 
        degs = (Exponent[#1, x]&)/@
            Transpose[FactorList[f, Modulus -> p]]
                [[1]]; 
        Return[(Select[#1 - 1, Positive] + 1&)[degs]]]

\(\(
galois2[f_]\  := \ 
      Module[{ff, \ clff, \ clf, g, h, h1, \ hroots, \ theta, \ clg, \ p, q, 
          r}, 
		clf\  = \ CoefficientList[f, x]; 
		
        If[Length[clf]\  != 5, \ 
           (*Print[" Polynomial is not quartic."]; *) 
			Return[0]]; 
        
	If[Not[IrreducibleQ[f]], \ 
			
           (*Print[\ "Polynomial is not irreducible."]; *) 
		
          Return[0]
	]; 
			ff\  = \ Expand[\((1/clf[\([5]\)])\)*f]; 

        		clff\  = \ CoefficientList[ff, x]; 
	\ 
        g\  = \ Expand[ff\  /. x\  -> \ x - clf[\([4]\)]/4]; 
	
			
        clg\  = \ CoefficientList[g, x]; 
		p\  = \ clg[\([3]\)]; 
		
        q\  = \ clg[\([2]\)]; 
		r\  = \ clg[\([1]\)]; 
		
        h\  = \ Together[resolvantCubic[g]]; 
		h1\  = \ h*Denominator[h]; 
        
		disc\  = \ Discriminant[f]; 
	
        If[
	IntegerQ[Sqrt[disc]], 
		
          If[
			IrreducibleQ[h1], 
				
             (*\ Print\ ["Galois group is A_4"]; *) \ 
				
            Return[1], 
			 (*Print\ ["Galois group is V"]; \ *) 

            				Return[2]
			]\  (*endif*) , 

			
          If[
					IrreducibleQ[h1], \ 
             (*Print[\ "Galois group is S_4"]; \ *) 
				Return[3], 
            
				
             (*Print\ [
                \(\*"""Galois\ group\ is\ Z_  4\ or\ D_  4 \*""]"\)*) 

            			\ \ \ \ \ ]\  (*endif*) 
	
	]\  (*endif*) ; 

		
        If[disc\  < \ 0, 
			
           (*\ Print[
              "Negative Discriminant implies Galois group is D_4."]; *) 

          				Return[4]
			]; 

        For[n\  = \ 1, \ n <= 2000, \ \(n++\), 
			pp\  = \ Prime[n]; 

          			If[
            \((FactorType[f, Prime[n]]\  == \ {2}\  && 
						
                Mod[disc, pp] != 0)\), 
				
             (*Print[
                "f has positive discriminant,not a square. Galois group has a 2-cycle. Hence Galois group is D_4."]; *) \ Return[4]
			]\ 
           (*endif*) 
]; 
	 (*	Print["Galois group is Z_4."]; *) 

        					Return[5]
		]
\)\)

\(ri\  := \ Random[Integer, \ {\(-100\), \ 100}]
\)\(FrequencyCountGalois\ [NN_]\  := \ 
      Module[{count, \ i, \ f, \ j, \ frequencies, NNN}, 
	
        count\  = \ Table[0, \ {6}]; 
		NNN = \ NN; 	

        For[i\  = \ 1, \ i <= NN, \ \ \(i++\), 

          f\  = \ \ x^4\  + \ ri\ x^3\  + \ ri\ x^2\  + \ ri\ x\  + \ ri; 
	
          j\  = \ galois2[f]; 
		
          If[\((j\  != \ 3\  && \ j\  != \ 0\  && \ j\  != \ 4)\), \ 
            Print[f, "    ", \ j]]; 		
	\(count[\([j + 1]\)]++\)	

          	]; 
		NNN\  = \ NN - \ count[\([1]\)]; 
		
        frequencies\  = \ N[\((1/NNN)\)*count]
		]
\)

FrequencyCountGalois[10^6]

\(\(FrequencyCountDiscriminant\ [NN_]\  := \ 
      Module[{count, \ i, \ f, \ j, \ frequencies, NNN}, 
	
        count\  = \ Table[0, \ {3}]; 
		NNN = \ NN; 	

        For[i\  = \ 1, \ i <= NN, \ \ \(i++\), 

          f\  = \ \ x^4\  + \ ri\ x^3\  + \ ri\ x^2\  + \ ri\ x\  + \ ri; 
	
          disc\  = \ Discriminant[f]; 
			
          If[Not[IntegerQ[disc]], \ \(count[\([1]\)]++\)]; 
		
          If[IntegerQ[Sqrt[disc]], \ \(count[\([2]\)]++\), \ 
            \(count[\([3]\)]++\)]; 
	]; 

		
        frequencies\  = \ N[\((1/NN)\)*count]
		]
\)\)

\(GenGalois[NN_]\  := 
	
      Module[
		{i, f, j}, 
		
        For[i\  = \ 1, \ i <= NN, \ \ \(i++\), 

          f\  = \ ri\ x^4\  + \ ri\ x^3\  + \ ri\ x^2\  + \ ri\ x\  + \ ri; 

          	j\  = \ galois2[f]; 
	
          If[\((j\  != \ 3\  && \ j\  != \ 0)\), \ Print[f, "    ", \ j]]
            
	]
]\)

GenGalois[10000]

f = 82 + 59*x + 24*x^2 + 3*x^3 + x^4
galois[f]
TeXForm[f]

f = 40  +  48*x  +  44*x^2  +  12*x^3  +  x^4galois[f]TeXForm[f]

f = 21 + 6*x - 17*x^2 + 3*x^3 + 21*x^4
galois[f]
TeXForm[f]

f = 1 - 12*x + 36*x^2 - 19*x^4
galois1[f]
TeXForm[f]

f = -17 - 50*x - 43*x^2 - 2*x^3 - 33*x^4 
galois[f] 
TeXForm[f]

f = -8 - 18*x^2 - 49*x^4 
galois1[f]
TeXForm[f]

f = -33 + 16*x - 39*x^2 + 26*x^3 - 9*x^4
galois[f]
TeXForm[f]

f  =  ri x^4  +  ri x^3  +  ri x^2  +  ri x  +  ri galois[f]