# Linearity vs. Flatness

Introduction

Linearity and flatness are two important metrics used to evaluate the performance of electronic devices, such as amplifier gain or frequency response in a radio system or in the data converter Analog-to-Digital Converter (ADC). However, these terms are often misunderstood. In this explanation, we will provide background information on linearity and flatness and discuss their real-world applications.

Example of Linearity on the left and flatness on the right

Background

Electronic System

An electronic system refers to a circuit that processes input signals to produce the desired output.

System Response

The system response represents the output of the electronic system when it is excited with valid input signals. This response can be in the form of voltage, current, or power. Common evaluations of the response include gain, frequency response, phase response, and distortion.

Linearity

A linear function describes a system where the output, with respect to its input, can be plotted as a straight line. The steepness or shape of the line is represented by a proportional constant, known as the slope. Linearity is mathematically defined by principles of superposition, additivity, and homogeneity. In other words, the output (Y) of a linear system is a linear combination of the input variable (X). For example, f(ax+bz) = af(x) + bf(z). A classic example of a linear electronic circuit is Ohm's Law: voltage (V) equals current (I) multiplied by resistance (R).

Conversely, In a nonlinear system, the relationship between the input and output is not a straightforward, proportional one. This means that doubling the input, for instance, won't necessarily double the output. classic example is the equation for electrical power dissipated in a resistor, given by:

P=V^2/R.

Here, the power P changes as the square of the voltage V, not linearly with it. This is a quadratic relationship, not a straight-line one, making it a good example of a nonlinear system.

Even in systems that are designed to be linear, like data converters (ADCs and DACs), nonlinearity can still occur. This deviation from ideal linear behavior can affect the system's performance and is quantified using specific metrics such as maximum deviation from an ideal straight line, Total Harmonic Distortion (THD), and or gain error.

### Metrics to Quantify Nonlinearity in Linear Systems

Maximum Deviation from an Ideal Straight Line: This measures how far the actual system response deviates away from a perfectly straight line, which would be the ideal in a linear system.

Total Harmonic Distortion (THD): This is a measure of the harmonic content that is added to the signal as it passes through the system. High THD usually indicates a significant amount of nonlinearity.

Gain Error: This measures how much the system's amplification factor deviates from its ideal or expected value. A gain error indicates that the system is not scaling the input to the output as expected.

Flatness

Flatness refers to the amplitude variation of a system's response over a specific frequency range, often characterized as amplitude error. This analysis focuses on how consistent the amplitude remains across different frequencies. A flat frequency response means that the amplitude does not vary significantly across the desired frequency range. However, it is important to note that a system can be flat but not linear. For instance, the frequency response amplitude may be constant across the desired range, but the gain may deviate from linearity due to amplifier output compression near the clipping point. If this clipping happens, we will see harmonics distortion presented in the frequency domain.

Metrics to Quantify Flatness in Systems

Amplitude Error: This metric quantifies the degree to which the amplitude deviates from a constant value across a given frequency range. A lower amplitude error indicates a flatter system.

Example of Bluetooth Transmission Spectrum Mask for evaluating Flatness: Source TEKTRONIC_Bluetooth_Poster

In short, Linearity is a time-domain property related to the system's response to a combination of signals . Flatness is a frequency-domain property related to how a system responds to different frequencies within a signal

Summary & Conclusion:

### Linear Systems

Exhibit a system response that can be plotted as a straight line.

Follow the principles of superposition and scalability.

Linearity is a property of the system and is independent of the input signal.

### Nonlinear Systems

Show a system response where the output is not directly proportional to the inputs.

Common causes of nonlinearity include saturation and clipping.

Result in signal distortion that shows up as harmonic frequencies in the frequency spectrum.

### Flatness

Characterizes the amplitude variation across a frequency range.

Can be applied to both the signal (spectral contents) and the system (frequency response).

### Note: It is important to note that an electronic system does not have to be strictly linear or flat; it can exhibit any combination of these characteristics. However, for most mixed-signal circuits and amplifiers, a preference is given to linear and flat systems. In audio digital signal processing, nonlinear and nonflat algorithms may be used for applications such as speaker protection and sound effects, respectively.

### For further reading, you can refer to the provided links:

"Linearity": [Link: http://www-math.mit.edu/~djk/calculus_beginners/chapter03/section03.html]

"Linear System": [Link: https://www.dspguide.com/ch5/4.htm]

"How to Measure Gain and Flatness": [Link: http://na.support.keysight.com/vna/help/latest/Tutorials/Gain_Flat.htm]