(*Illustrating ordinary amplitude modulation power efficiency 
by Nasser M. Abbasi
version August 31 2009*)

Manipulate[
 am[\[Micro], fc, fm, showCarrier, showMessage],
 
 Style["modulation parameters", Bold],
 {{\[Micro], 0.8, "\[Micro]"}, 0, 1.3, .1, Appearance -> "Labeled", 
  ImageMargins -> -2, ImageSize -> Small},
   {{fc, 7000, "\!\(\*SubscriptBox[\(f\), \(c\)]\) (hz)"}, 5000, 
  10000, 100, Appearance -> "Labeled", ImageMargins -> -2, 
  ImageSize -> Small},
   {{fm, 500, "\!\(\*SubscriptBox[\(f\), \(m\)]\) (hz)"}, 300, 1000, 
  10, Appearance -> "Labeled", ImageMargins -> -2, ImageSize -> Small},
 Delimiter,      
 Style["modulated carrier plot options", Bold],
 {{showCarrier, True, "show carrier "}, {True, False}},
 {{showMessage, True, "show message "}, {True, False}}
 ,
 ControlPlacement -> Left,
 Initialization :>
  (
   maxCarrierFreq = 10000;
   maxMessageFreq = 1000;
   tmax = 3;
   fontSizeForTitles = 14;
   fontSizeForSubTitles = 11;
   
   am[\[Micro]_, fc_, fm_, showCarrier_, showMessage_] := 
    Module[{plotStyleForCarrier, messagePlot, envelopePlot, 
      carrierPlot, p},
     
     carrierPlot = (1 + \[Micro]  Cos[2 Pi fm t/1000]) Cos[
        2 Pi fc t/1000];
     messagePlot = Cos[2 Pi fm t/1000];
     envelopePlot = 1 + \[Micro]  Cos[2 Pi fm t/1000];
     
     If[showCarrier == True && 
       showMessage == 
        True, {plotStyleForCarrier = {Red, 
         Blue, {Black, Dashed, Thin}},
       p = {carrierPlot, messagePlot, envelopePlot}}];
     
     If[showCarrier == True && 
       showMessage == 
        False, {plotStyleForCarrier = {Red, {Black, Dashed, Thin}},
       p = {carrierPlot, envelopePlot}}];
     
     If[showCarrier == False && 
       showMessage == 
        True, {plotStyleForCarrier = {Blue, {Black, Dashed, Thin}},
       p = {messagePlot, envelopePlot}}];
     
     If[showCarrier == False && 
       showMessage == 
        False, {plotStyleForCarrier = {{Black, Dashed, Thin}},
       p = envelopePlot}];
     
     
     GraphicsGrid[{
       {  
        Plot[ Cos[2 Pi fc t/1000] , {t, 0, 2}, TicksStyle -> Small, 
         Ticks -> {{0, 1, 2}, {-1, 0, 1}}, 
         AxesLabel -> {Style[Row[{Style["t", Italic], " (ms)"}], 
            Larger]}, 
         PlotLabel -> Style["carrier signal", fontSizeForTitles], 
         PlotStyle -> Red, Exclusions -> {1}],
        
        Plot[ Cos[2 Pi fm t/1000] , {t, 0, 2}, TicksStyle -> Small, 
         Ticks -> {{0, 1, 2}, {-1, 0, 1}}, 
         AxesLabel -> {Style[Row[{Style["t", Italic], " (ms)"}], 
            Larger]}, 
         PlotLabel -> Style["message signal", fontSizeForTitles], 
         PlotStyle -> Blue, Exclusions -> {1}]
        },
       
       {Plot[p,
         {t, 0, tmax },
         PlotRange -> {All, {-2.5, 2.5}}, TicksStyle -> Small, 
         AxesLabel -> {Style[Row[{Style["t", Italic], " (ms)"}], 
            Larger]}, 
         PlotLabel -> 
          Column[{Style["modulated carrier", fontSizeForTitles], 
            Style["with envelope and orginal message superimposed", 
             fontSizeForSubTitles]}, Center],
         PlotStyle -> plotStyleForCarrier, ImagePadding -> Full, 
         Exclusions -> {1}], SpanFromLeft
        },
       
       {frequencyPlot[fm, fc, \[Micro]], SpanFromLeft}},
      Spacings -> {Scaled[.1], Scaled[.1]}, Frame -> {False, All}, 
      Dividers -> None, AspectRatio -> Full, ImageSize -> 320]
     ];
   frequencyPlot[fm_, fc_, \[Micro]_] := 
    Module[{carrierRight, carrierLeft, upperRight, upperleft, 
      lowerRight, lowerleft, carrierPower, sidePower, 
      z = 0.7*maxCarrierFreq, g, plotLabel},
     carrierRight = {Red, Arrow[{{fc, 0}, {fc, .5*fc}}] };
     carrierLeft = {Red, Arrow[{{-fc, 0}, {-fc, 0.5*fc}}]};
     upperRight = {Blue, 
       Arrow[{{fc + fm, 0}, {fc + fm, fc*\[Micro]/4.}}]};
     upperleft = {Blue, 
       Arrow[{{fc - fm, 0}, {fc - fm, fc*\[Micro]/4.}}]};
     lowerRight = {Blue, 
       Arrow[{{-fc + fm, 0}, {-fc + fm, fc*\[Micro]/4.}}]};
     lowerleft = {Blue, 
       Arrow[{{-fc - fm, 0}, {-fc - fm, fc*\[Micro]/4.}}]};
     carrierPower = 0.5;
     sidePower = \[Micro]^2/4.;
     
     g = {   
       Line[{{-maxCarrierFreq - 0.1*maxCarrierFreq, 
          0}, {maxCarrierFreq + 0.1*maxCarrierFreq, 0}}],  
       Line[{{0, 0}, {0, .25*z}}], 
       carrierRight, 
       carrierLeft, 
       upperRight, 
       upperleft,
       lowerRight,
       lowerleft,
       Text[
        Style["-\!\(\*SubscriptBox[\(f\), \(c\)]\)", 
         Small], {-fc, -0.1*z}],
       Text[
        Style["\!\(\*SubscriptBox[\(f\), \(c\)]\)", 
         Small], {fc, -0.1*z}],
       Text[Style["0", Small], {0, -0.1*z}]
       };
     
     plotLabel = 
      Style[Column[{ 
         Style["modulated carrier frequency (magnitude)", 
          fontSizeForTitles] ,
         Row[{Style["carrier power = 0.5 watt, ", 
            fontSizeForSubTitles],
           
           Style["sidebands power = " <> 
             ToString[NumberForm[sidePower, {3, 3}]] <> " watt", 
            fontSizeForSubTitles]}], 
         Style["modulation efficiency = " <> 
           ToString[
            NumberForm[\[Micro]^2/(\[Micro]^2 + 2)*100, {3, 2}]] <> 
           "%", fontSizeForSubTitles]
         }, Center]] ;
     
     ListPlot[{{0, 0}}, 
      PlotRange -> {{-maxCarrierFreq - 0.3*maxCarrierFreq, 
         maxCarrierFreq + 0.3*maxCarrierFreq}, {-10, 
         0.5*maxCarrierFreq}},
      PlotLabel -> plotLabel, Ticks -> {{-fc, 0, fc}, None},
      AxesLabel -> {Style[Row[{Style["f", Italic], " (hz)"}], 
         Larger]}, ImagePadding -> Full,
      Epilog -> g]
     ]
   )
 ]