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[fAngle_] := 
            activeY[-Pi/2 + th] . activeX[-fAngle] . 
              activeY[Pi/2 - th];
Print["X-pulse matrix:"]
MatrixForm[Xpulse[aX]]

  
  
  
  
mXpulse[fAngle2_] = 
            activeY[-Pi/2 - th] . activeX[-fAngle2] . 
              activeY[Pi/2 + th];
Print["-X-pulse matrix:"]
MatrixForm[mXpulse[amX]]

  
  
compositePulse = 
            Xpulse[fAng270] . mXpulse[fAng180] . Xpulse[fAng90];

Print["xcomponent of \
X(t90)-X(t180)X(t270)-composite pulse:"]

Mxvector  =  
          FullSimplify[compositePulse[[1 , 3]]]
Mxvector = 
          Mxvector /.  {Cos[2  th]  ->  TrigExpand[Cos[2  th]],  
              Sin[2  th]  -> TrigExpand[Sin[2  th]]}

xComponent[db0_]  =  
            Mxvector  /.  {
Cos[th]  ->  
                  db0/Sqrt[b1*b1 + db0*db0], 
Sin[
                    th]  -> 
                  b1/Sqrt[
                      b1*b1 + db0*db0], 
fAng90  ->  
                  2  Pi*t90*
                    Sqrt[b1*b1 + 
                        db0*db0], 
fAng180 ->  
                  2  Pi*t180*
                    Sqrt[b1*b1 + 
                        db0*db0], 
fAng270 ->  
                  2  Pi*t270*Sqrt[b1*b1 + db0*db0]
};

Print["ycomponent of \
X(t90)-X(t180)X(t270)-composite pulse:"]

Myvector  =  
          FullSimplify[compositePulse[[2 , 3]]]
Myvector = 
          Myvector /.  {Cos[2  th]  ->  TrigExpand[Cos[2  th]],  
              Sin[2  th]  -> TrigExpand[Sin[2  th]]}

yComponent[db0_]  =  
            Myvector  /.  {
Cos[th]  ->  
                  db0/Sqrt[b1*b1 + db0*db0], 
Sin[
                    th]  -> 
                  b1/Sqrt[
                      b1*b1 + db0*db0], 
fAng90  ->  
                  2  Pi*t90*
                    Sqrt[b1*b1 + 
                        db0*db0], 
fAng180 ->  
                  2  Pi*t180*
                    Sqrt[b1*b1 + 
                        db0*db0], 
fAng270 ->  
                  2  Pi*t270*Sqrt[b1*b1 + db0*db0]
};

Print["zcomponent of \
X(t90)-X(t180)X(t270)-composite pulse:"]

Mzvector  =  
          FullSimplify[compositePulse[[3 , 3]]]
Mzvector = 
          Mzvector /.  {Cos[2  th]  ->  TrigExpand[Cos[2  th]],  
              Sin[2  th]  -> TrigExpand[Sin[2  th]]}

zComponent[db0_]  =  
            Mzvector  /.  {
Cos[th]  ->  
                  db0/Sqrt[b1*b1 + db0*db0], 
Sin[
                    th]  -> 
                  b1/Sqrt[
                      b1*b1 + db0*db0], 
fAng90  ->  
                  2  Pi*t90*
                    Sqrt[b1*b1 + 
                        db0*db0], 
fAng180 ->  
                  2  Pi*t180*
                    Sqrt[b1*b1 + 
                        db0*db0], 
fAng270 ->  
                  2  Pi*t270*Sqrt[b1*b1 + db0*db0]
};
  
Print["-----------------------------------------------"]

  

b1 = 50;                
t90 = 0.005;       
t180 = 0.01;      
t270 = 0.015;    
nb = 70;               

For[m = 0,  
            m  <=  nb,  m++,  offset[m] = m; ];
offsetValue  =  
            Chop[Table[{off,  
                  offset[off],  
NumberForm[
                    xComponent[off],  10] , 
NumberForm[
                    yComponent[off],  10], 
NumberForm[
                    zComponent[off],  10]},  {off,  0,  nb}]];
\(Print[
          TableForm[offsetValue, \ 
            TableHeadings\  -> \ {None, \ {Rang, \ 
                  offset/kHz, "xMagnetization", \ "yMagnetization", \ "zMagnetization"\ }}]]\)
Print["-----------------------------------------------"]

  

\(plotComposite123x\  = \ 
          ListPlot[
            Table[{off, \ xComponent[off]}, \ {off, \ 0, \ 
                nb}], 
PlotLabel\  -> \ "xComponent 90°(X)180°(-X)270°(X)", 
PlotJoined\  -> \ 
              True, 
AxesLabel\  -> \ {"Offset (kHz)", \ \ "Mx"}, 
PlotStyle -> {Hue[ .1], \ 
                Thickness[
                  0.005]}, 
TextStyle\  -> \ {FontSize\  -> \ 12}, 
PlotRange -> \ 
              All
]\)

\(plotComposite123y\  = \ 
          ListPlot[
            Table[{off, \ yComponent[off]}, \ {off, \ 0, \ 
                nb}], 
PlotLabel\  -> \ "yComponent 90°(X)180°(-X)270°(X)", 
PlotJoined\  -> \ 
              
              True, 
AxesLabel\  -> \ {"Offset (kHz)", \ \ "My"}, 
PlotStyle -> {Hue[ .3], \ 
                Thickness[
                  0.005]}, 
TextStyle\  -> \ {FontSize\  -> \ 12}, 
PlotRange -> \ 
              All
]\)

\(plotComposite123z\  = \ 
          ListPlot[
            Table[{off, \ zComponent[off]}, \ {off, \ 0, \ 
                nb}], 
PlotLabel\  -> \ "zComponent 90°(X)180°(-X)270°(X)", 
PlotJoined\  -> \ 
              True, 
AxesLabel\  -> \ {"Offset (kHz)", \ \ "Mz"}, 
PlotStyle -> {Hue[ .5], \ 
                Thickness[
                  0.005]}, 
TextStyle\  -> \ {FontSize\  -> \ 12}, 
PlotRange -> \ 
              All
]\)

\(Show[{plotComposite123x, \ 
            plotComposite123y, \ 
            plotComposite123z}, 
PlotLabel\  -> \ "90°(X)180°(-X)270°(X)-detection", \ 
AxesLabel\  -> \ {"Offset (kHz)", \ \ "Mi"}
]\)

Remove[zComponent, activeX,  activeY,  
            activeZ,  Xpulse, mXpulse,  Mz,  offsetValue,  offset,  
            off,  nb,  b1,  th,  fAng90,  fAng180,  fAng270, fAngle, 
            fAngle2, th,  t90,  t180, t270,  compositePulse,  aX,  
            amX];