# Root mean square

In mathematics, the root mean square (abbrev. RMS, RMS or rms) of a set of values is the square root of the set's mean square. Given a set $x_{i}$, its RMS is denoted as either $x_{\mathrm {RMS} }$ or $\mathrm {RMS} _{x}$. The RMS is also known as the quadratic mean (denoted $M_{2}$), a special case of the generalized mean. The RMS of a continuous function is denoted $f_{\mathrm {RMS} }$ and can be defined in terms of an integral of the square of the function. In estimation theory, the root-mean-square deviation of an estimator measures how far the estimator strays from the data.

## Definition

The RMS value of a set of values (or a continuous-time waveform) is the square root of the arithmetic mean of the squares of the values, or the square of the function that defines the continuous waveform.
In the case of a set of n values $\{x_{1},x_{2},\dots ,x_{n}\}$, the RMS is
    $x_{\text{RMS}}={\sqrt {{\frac {1}{n}}\left({x_{1}}^{2}+{x_{2}}^{2}+\cdots +{x_{n}}^{2}\right)}}.$
The corresponding formula for a continuous function (or waveform) f(t) defined over the interval $T_{1}\leq t\leq T_{2}$ is
    $f_{\text{RMS}}={\sqrt {{1 \over {T_{2}-T_{1}}}{\int _{T_{1}}^{T_{2}}{[f(t)]}^{2}\,{\rm {d}}t}}},$
and the RMS for a function over all time is
    $f_{\text{RMS}}=\lim _{T\rightarrow \infty }{\sqrt {{1 \over {2T}}{\int _{-T}^{T}{[f(t)]}^{2}\,{\rm {d}}t}}}.$
The RMS over all time of a periodic function is equal to the RMS of one period of the function. The RMS value of a continuous function or signal can be approximated by taking the RMS of a sample consisting of equally spaced observations. Additionally, the RMS value of various waveforms can also be determined without calculus, as shown by Cartwright.
In the case of the RMS statistic of a random process, the expected value is used instead of the mean.

## In common waveforms

If the waveform is a pure sine wave, the relationships between amplitudes (peak-to-peak, peak) and RMS are fixed and known, as they are for any continuous periodic wave. However, this is not true for an arbitrary waveform, which may not be periodic or continuous. For a zero-mean sine wave, the relationship between RMS and peak-to-peak amplitude is:
    Peak-to-peak $=2{\sqrt {2}}\times {\text{RMS}}\approx 2.8\times {\text{RMS}}.$
For other waveforms, the relationships are not the same as they are for sine waves. For example, for either a triangular or sawtooth wave:
    Peak-to-peak $=2{\sqrt {3}}\times {\text{RMS}}\approx 3.5\times {\text{RMS}}.$
| Waveform | Variables and operators | RMS |
| DC | $y=A_{0}\,$ | $A_{0}\,$ |
| Sine wave | $y=A_{1}\sin(2\pi ft)\,$ | ${\frac {A_{1}}{\sqrt {2}}}$ |
| Square wave | $y={\begin{cases}A_{1}&\operatorname {frac} (ft)<0.5\\-A_{1}&\operatorname {frac} (ft)>0.5\end{cases}}$ | $A_{1}\,$ |
| DC-shifted square wave | $y=A_{0}+{\begin{cases}A_{1}&\operatorname {frac} (ft)<0.5\\-A_{1}&\operatorname {frac} (ft)>0.5\end{cases}}$ | ${\sqrt {A_{0}^{2}+A_{1}^{2}}}\,$ |
| Modified sine wave | $y={\begin{cases}0&\operatorname {frac} (ft)<0.25\\A_{1}&0.25<\operatorname {frac} (ft)<0.5\\0&0.5<\operatorname {frac} (ft)<0.75\\-A_{1}&\operatorname {frac} (ft)>0.75\end{cases}}$ | ${\frac {A_{1}}{\sqrt {2}}}$ |
| Triangle wave | $y=\left|2A_{1}\operatorname {frac} (ft)-A_{1}\right|$ | $A_{1} \over {\sqrt {3}}$ |
| Sawtooth wave | $y=2A_{1}\operatorname {frac} (ft)-A_{1}\,$ | $A_{1} \over {\sqrt {3}}$ |
| Pulse wave | $y={\begin{cases}A_{1}&\operatorname {frac} (ft)<D\\0&\operatorname {frac} (ft)>D\end{cases}}$ | $A_{1}{\sqrt {D}}$ |
| Phase-to-phase sine wave | $y=A_{1}\sin(t)-A_{1}\sin \left(t-{\frac {2\pi }{3}}\right)\,$ | $A_{1}{\sqrt {\frac {3}{2}}}$ |
| where: y is displacement,t is time,f is frequency,A$_i$ is amplitude (peak value),D is the duty cycle or the proportion of the time period (1/f) spent high,frac(r) is the fractional part of r. |||

### In waveform combinations

Waveforms made by summing known simple waveforms have an RMS value that is the root of the sum of squares of the component RMS values, if the component waveforms are orthogonal (that is, if the average of the product of one simple waveform with another is zero for all pairs other than a waveform times itself).
    ${\text{RMS}}_{\text{Total}}={\sqrt {{\text{RMS}}_{1}^{2}+{\text{RMS}}_{2}^{2}+\cdots +{\text{RMS}}_{n}^{2}}}$
Alternatively, for waveforms that are perfectly positively correlated, or "in phase" with each other, their RMS values sum directly.

## Uses
### In electrical engineering
#### Current

The RMS of an alternating electric current equals the value of constant direct current that would dissipate the same power in a resistive load.

#### Voltage

A special case of RMS of waveform combinations is:
    ${\text{RMS}}_{\text{AC+DC}}={\sqrt {{\text{V}}_{\text{DC}}^{2}+{\text{RMS}}_{\text{AC}}^{2}}}$
where ${\text{V}}_{\text{DC}}$ refers to the direct current (or average) component of the signal, and ${\text{RMS}}_{\text{AC}}$ is the alternating current component of the signal.

#### Average electrical power

Electrical engineers often need to know the power, P, dissipated by an electrical resistance, R. It is easy to do the calculation when there is a constant current, I, through the resistance. For a load of R ohms, power is given by:
    $P=I^{2}R.$
However, if the current is a time-varying function, I(t), this formula must be extended to reflect the fact that the current (and thus the instantaneous power) is varying over time. If the function is periodic (such as household AC power), it is still meaningful to discuss the average power dissipated over time, which is calculated by taking the average power dissipation:
    ${\begin{aligned}P_{\text{Avg}}&=\left(I(t)^{2}R\right)_{\text{Avg}}&&{\text{where }}(\cdots )_{\text{Avg}}{\text{ denotes the temporal mean of a function}}\\[3pt]&=\left(I(t)^{2}\right)_{\text{Avg}}R&&{\text{(as }}R{\text{ does not vary over time, it can be factored out)}}\\[3pt]&=I_{\text{RMS}}^{2}R&&{\text{by definition of root-mean-square}}\end{aligned}}$
So, the RMS value, I$_{RMS}$, of the function I(t) is the constant current that yields the same power dissipation as the time-averaged power dissipation of the current I(t).
Average power can also be found using the same method that in the case of a time-varying voltage, V(t), with RMS value V$_{RMS}$,
    $P_{\text{Avg}}={V_{\text{RMS}}^{2} \over R}.$
This equation can be used for any periodic waveform, such as a sinusoidal or sawtooth waveform, allowing us to calculate the mean power delivered into a specified load.
By taking the square root of both these equations and multiplying them together, the power is found to be:
    $P_{\text{Avg}}=V_{\text{RMS}}I_{\text{RMS}}.$
Both derivations depend on voltage and current being proportional (that is, the load, R, is purely resistive). Reactive loads (that is, loads capable of not just dissipating energy but also storing it) are discussed under the topic of AC power.
In the common case of alternating current when I(t) is a sinusoidal current, as is approximately true for mains power, the RMS value is easy to calculate from the continuous case equation above. If I$_p$ is defined to be the peak current, then:
    $I_{\text{RMS}}={\sqrt {{1 \over {T_{2}-T_{1}}}\int _{T_{1}}^{T_{2}}\left[I_{\text{p}}\sin(\omega t)\right]^{2}dt}},$
where t is time and ω is the angular frequency (ω = 2π/T, where T is the period of the wave).
Since I$_p$ is a positive constant and was to be squared within the integral:
    $I_{\text{RMS}}=I_{\text{p}}{\sqrt {{1 \over {T_{2}-T_{1}}}{\int _{T_{1}}^{T_{2}}{\sin ^{2}(\omega t)}\,dt}}}.$
Using a trigonometric identity to eliminate squaring of trig function:
    ${\begin{aligned}I_{\text{RMS}}&=I_{\text{p}}{\sqrt {{1 \over {T_{2}-T_{1}}}{\int _{T_{1}}^{T_{2}}{1-\cos(2\omega t) \over 2}\,dt}}}\\[3pt]&=I_{\text{p}}{\sqrt {{1 \over {T_{2}-T_{1}}}\left[{t \over 2}-{\sin(2\omega t) \over 4\omega }\right]_{T_{1}}^{T_{2}}}}\end{aligned}}$
but since the interval is a whole number of complete cycles (per definition of RMS), the sine terms will cancel out, leaving:
    $I_{\text{RMS}}=I_{\text{p}}{\sqrt {{1 \over {T_{2}-T_{1}}}\left[{t \over 2}\right]_{T_{1}}^{T_{2}}}}=I_{\text{p}}{\sqrt {{1 \over {T_{2}-T_{1}}}{{T_{2}-T_{1}} \over 2}}}={I_{\text{p}} \over {\sqrt {2}}}.$
A similar analysis leads to the analogous equation for sinusoidal voltage:
    $V_{\text{RMS}}={V_{\text{p}} \over {\sqrt {2}}},$
where I$_P$ represents the peak current and V$_P$ represents the peak voltage.
Because of their usefulness in carrying out power calculations, listed voltages for power outlets (for example, 120 V in the US, or 230 V in Europe) are almost always quoted in RMS values, and not peak values. Peak values can be calculated from RMS values from the above formula, which implies V$_P$ = V$_{RMS}$ × √2, assuming the source is a pure sine wave. Thus the peak value of the mains voltage in the USA is about 120 × √2, or about 170 volts. The peak-to-peak voltage, being double this, is about 340 volts. A similar calculation indicates that the peak mains voltage in Europe is about 325 volts, and the peak-to-peak mains voltage, about 650 volts.
RMS quantities such as electric current are usually calculated over one cycle. However, for some purposes the RMS current over a longer period is required when calculating transmission power losses. The same principle applies, and (for example) a current of 10 amps used for 12 hours each 24-hour day represents an average current of 5 amps, but an RMS current of 7.07 amps, in the long term.
The term RMS power is sometimes erroneously used (e.g., in the audio industry) as a synonym for mean power or average power (it is proportional to the square of the RMS voltage or RMS current in a resistive load). For a discussion of audio power measurements and their shortcomings, see Audio power.

### Speed

In the physics of gas molecules, the root-mean-square speed is defined as the square root of the average squared-speed. The RMS speed of an ideal gas is calculated using the following equation:
    $v_{\text{RMS}}={\sqrt {3RT \over M}}$
where R represents the gas constant, 8.314 J/(mol·K), T is the temperature of the gas in kelvins, and M is the molar mass of the gas in kilograms per mole. In physics, speed is defined as the scalar magnitude of velocity. For a stationary gas, the average speed of its molecules can be in the order of thousands of km/h, even though the average velocity of its molecules is zero.

### Error

When two data sets — one set from theoretical prediction and the other from actual measurement of some physical variable, for instance — are compared, the RMS of the pairwise differences of the two data sets can serve as a measure of how far on average the error is from 0. The mean of the absolute values of the pairwise differences could be a useful measure of the variability of the differences. However, the RMS of the differences is usually the preferred measure, probably due to mathematical convention and compatibility with other formulae.

## In frequency domain

The RMS can be computed in the frequency domain, using Parseval's theorem. For a sampled signal $x[n]=x(t=nT)$, where $T$ is the sampling period,
    $\sum _{n=1}^{N}{x^{2}[n]}={\frac {1}{N}}\sum _{m=1}^{N}\left|X[m]\right|^{2},$
where $X[m]=\operatorname {DFT} \{x[n]\}$ and N is the sample size, that is, the number of observations in the sample and DFT coefficients.
In this case, the RMS computed in the time domain is the same as in the frequency domain:
    ${\text{RMS}}\{x[n]\}={\sqrt {{\frac {1}{N}}\sum _{n}{x^{2}[n]}}}={\sqrt {{\frac {1}{N^{2}}}\sum _{m}{{\bigl |}X[m]{\bigr |}}^{2}}}={\sqrt {\sum _{m}{\left|{\frac {X[m]}{N}}\right|^{2}}}}.$

## Relationship to other statistics

The standard deviation $\sigma _{x}=(x-{\overline {x}})_{\text{rms}}$ of a population or a waveform $x$ is the RMS deviation of $x$ from its arithmetic mean ${\bar {x}}$. They are related to the RMS value of $x$ by
    $\sigma _{x}^{2}={\overline {(x-{\overline {x}})^{2}}}=x_{\text{rms}}^{2}-{\overline {x}}^{2}$.
From this it is clear that the RMS value is always greater than or equal to the average, in that the RMS includes the squared deviation (error) as well.
Physical scientists often use the term root mean square as a synonym for standard deviation when it can be assumed the input signal has zero mean, that is, referring to the square root of the mean squared deviation of a signal from a given baseline or fit. This is useful for electrical engineers in calculating the "AC only" RMS of a signal. Standard deviation being the RMS of a signal's variation about the mean, rather than about 0, the DC component is removed (that is, RMS(signal) = stdev(signal) if the mean signal is 0).