Question: Kind of new to *Mathematica*. I am plotting a function that produces a bell-shaped curve in *Mathematica* within a `Manipulate` so that I can change its parameters easily. When I change the parameters of the function with the controls, I want the width of the bell-shaped curve at half its peak value recalculated.

How do I add this additional feature?

Answer: 
This function will find the full-width at half-maximum for an arbitrary function within a given range, provided that there is only one peak in that range:

```
fwhm[func_Function, {min_, max_}] := Module[{val, maxx, x},
  {val, maxx} = {#1, x /. #2} & @@ 
    NMaximize[{func[x], x > min, x < max}, x];
  Chop@{maxx, 
    Abs[#1 - #2] & @@ (x /. 
       NSolve[{func[x] == val/2, x > min, x < max}, x])}]

```

The returned values are the peak position, and the FWHM value.

```
fwhm[Sin[#]/(#) &, {-10, 10}]
fwhm[Function[y, Exp[-y^2/2]], {-10, 10}]
fwhm[Re[I/(# - 2. + 3. I)] &, {-10, 10}]
fwhm[Function[y, Sin[π y]], {4, 5}]
fwhm[Function[y, 1 - y^2/3^2], {-10, 10}]
(* {-2.21056*10^-9, 3.79099} *)
(* {0, 2.35482} *)
(* {2., 6.} *)
(* {4.5, 0.666667} *)
(* {0, 4.24264} *)

```

These values match what you find at [MathWorld](http://mathworld.wolfram.com/FullWidthatHalfMaximum.html) (can you spot the typo there?)

You can integrate this into a `Manipulate` call, it's a reasonably fast function.

```
Manipulate[
 Module[{peak, width},
  {peak, width} = fwhm[Exp[-#^2/(2 a)] &, {-20, 20}];
  Show[
   Plot[Exp[-x^2/(2 a)], {x, -10, 10}, PlotRange -> All, 
    Frame -> True, Axes -> False],
   Graphics[{Arrowheads[{-.05, .05}], Arrow[{
       {peak - .5 width, Exp[-(peak - .5 width)^2/(2 a)]},
       {peak + .5 width, Exp[-(peak + .5 width)^2/(2 a)]}}
      ]}],
   Epilog -> Inset[Row[{"FWHM = ", width}], {7, .8}]
   ]
  ]
 , {{a, 1}, .5, 10}]

```

[![enter image description here](https://i.stack.imgur.com/vPIGl.gif)](https://i.stack.imgur.com/vPIGl.gif)
Solve for the width at half height as a function of $\sigma$, then just list it:

```
Manipulate[{
  Plot[PDF[NormalDistribution[0, σ], x], {x, -3, 3},
   PlotRange -> All], 
  N@Sqrt[2] σ Sqrt[Log[2]]},
  {σ, .1, 3}]

```