activeX[
              u_] := {{1,  0,  0}, {0,  Cos[u],  -Sin [u]}, {0,  
                Sin [u],  Cos[u]}};
activeY[
              u_] := {{ Cos[u], 0,  Sin [u]}, {0,  1,  
                0}, {-Sin [u], 0,   Cos[u]}};
activeZ[
              u_] := {{Cos[u],  -Sin [u],  0}, {Sin [u],  Cos[u], 
                0 },  {0,  0,  1}};

MatrixForm[activeX[a]];
MatrixForm[activeY[a]];
MatrixForm[activeZ[a]];

  
  
Xpulse = 
            activeY[-Pi/2 + th] . activeX[-fAng] . 
              activeY[Pi/2 - th];
Print["X-pulse matrix:"]
MatrixForm[Xpulse]

Print["Z-component of X(180)-one \
pulse:"]
Mz1  =  Xpulse[[3 , 3]]
zComponent1[db0_]  =  
            Mz1  /.  {
Cos[th]  ->  
                  db0/Sqrt[b1*b1 + db0*db0], 
Sin[
                    th]  -> 
                  b1/Sqrt[
                      b1*b1 + db0*db0], 
fAng  ->  
                  2  Pi*t*Sqrt[b1*b1 + db0*db0]
};

  
  
Ypulse = 
            activeX[Pi/2 - th] . activeY[-fAng2] . 
              activeX[-Pi/2 + th];
Print["Y-pulse matrix:"]
MatrixForm[Ypulse]

  
  
compositePulse = Xpulse . Ypulse . Xpulse;

Print["Z-component of \
X(t)Y(tau)X(t)-composite pulse:"]
Mz  =  
          FullSimplify[compositePulse[[3 , 3]]]

zComponent[db0_]  =  
            Mz  /.  {
Cos[th]  ->  
                  db0/Sqrt[b1*b1 + db0*db0], 
Sin[
                    th]  -> 
                  b1/Sqrt[
                      b1*b1 + db0*db0], 
fAng  ->  
                  2  Pi*t*
                    Sqrt[b1*b1 + db0*db0], 
fAng2 ->  
                  2  Pi*tau*Sqrt[b1*b1 + db0*db0]
};

  
Print["-----------------------------------------------"]

  

b1 = 50;           
t = 0.005;       
tau = 0.01;    
nb = 70;           

For[m = 0,  
            m  <=  nb,  m++,  offset[m] = m; ];
offsetValue  =  
            Chop[Table[{off,  offset[off],  
                  NumberForm[zComponent[off],  10]},  {off,  0,  nb}]];
\(Print[
          TableForm[offsetValue, \ 
            TableHeadings\  -> \ {None, \ {Rang, \ 
                  offset/kHz, "zMagnetization/X(90°)Y(180°)X(90°)"\ }}]]\)
Print["-----------------------------------------------"]

  

tau = 0.0133333;      

For[m = 0,  
            m  <=  nb,  m++,  offset[m] = m; ];
offsetValue  =  
            Chop[Table[{off,  offset[off],  
                  NumberForm[zComponent[off],  10]},  {off,  0,  nb}]];
\(Print[
          TableForm[offsetValue, \ 
            TableHeadings\  -> \ {None, \ {Rang, \ 
                  offset/kHz, "zMagnetization/X(90°)Y(240°)X(90°)"\ }}]]\)
Print["-----------------------------------------------"]

  

t = 0.01;     

For[m = 0,  
            m  <=  nb,  m++,  offset[m] = m; ];
offsetValue  =  
            Chop[Table[{off,  offset[off],  
                  NumberForm[zComponent1[off],  10]},  {off,  0,  
                  nb}]];
Print[
          TableForm[offsetValue,  
            TableHeadings  ->  {None,  {Rang,  
                  offset/kHz, "zMagnetization/X(180°)" }}]]
Print["-----------------------------------------------"]

  

b1 = 50;           
t = 0.005;       
tau = 0.01;    
nb = 70;           

\(plotComposite180\  = \ 
            ListPlot[
              Table[{off, \ zComponent[off]}, \ {off, \ 0, \ 
                  nb}], 
PlotLabel\  -> \ "X(90°)Y(180°)X(90°)composite pulse", 
PlotJoined\  -> \ 
                True, 
AxesLabel\  -> \ {"Offset (kHz)", \ \ "Mz"}, 
PlotStyle -> 
                Hue[ .3], 
TextStyle\  -> \ {FontSize\  -> \ 12}
]\)

  

tau = 0.0133333;      
\(plotComposite240\  = \ 
            ListPlot[
              Table[{off, \ zComponent[off]}, \ {off, \ 0, \ 
                  nb}], 
PlotLabel\  -> \ "X(90°)Y(240°)X(90°) composite pulse", 
PlotJoined\  -> \ 
                True, 
AxesLabel\  -> \ {"Offset (kHz)", \ "Mz"}, 
PlotStyle -> 
                Hue[ .1], 
TextStyle\  -> \ {FontSize\  -> \ 12}
]\)

  

t = 0.01;     
\(plotOne\  = \ 
            ListPlot[
              Table[{off, \ zComponent1[off]}, \ {off, \ 0, \ 
                  nb}], 
PlotLabel\  -> \ "X(180°) pulse", 
PlotJoined\  -> \ 
                True, 
AxesLabel\  -> \ {"Offset (kHz)", \ "Mz"}, 
PlotStyle -> 
                Hue[ .6], 
TextStyle\  -> \ {FontSize\  -> \ 12}
]\)

Show[{plotComposite180,  
            plotComposite240,  plotOne}, 
 
          PlotLabel  ->  ""]

Remove[zComponent,  zComponent1,  
          activeX,  activeY,  activeZ,  Xpulse, Ypulse,  Mz,  Mz1,  
          offsetValue,  offset,  off,  nb,  t,  tau,  b1,  th,  
          fAng,  fAng2]