Gain Margin Calculator Formula

Understand the math behind the gain margin calculator. Each variable explained with a worked example.

Formulas Used

Gain Margin (absolute)

gm_abs = 1 / gain_at_180

Gain Margin

gm_db = -20 * log10(gain_at_180)

Maximum Gain Increase Before Instability

max_gain_increase = (1 / gain_at_180 - 1) * 100

Variables

VariableDescriptionDefault
gain_at_180Open-Loop Gain at Phase = -180° (|G|)0.5

How It Works

Gain Margin

Gain margin measures how much the open-loop gain can increase before the system becomes unstable. It is evaluated at the phase crossover frequency (where the open-loop phase equals -180°).

Formula

GM = 1 / G(j*omega_pc)= -20*log10(G(j*omega_pc)) dB

where omega_pc is the phase crossover frequency. A positive gain margin (in dB) indicates stability. The larger the gain margin, the more robust the system is to gain variations.

Worked Example

The open-loop gain magnitude at -180° phase is 0.5.

gain_at_180 = 0.5
  1. 01GM = 1 / 0.5 = 2.0 (absolute)
  2. 02GM = -20 × log10(0.5) = -20 × (-0.301) = 6.02 dB
  3. 03The gain can be increased by 100% before instability

Frequently Asked Questions

What is a good gain margin?

A gain margin of at least 6 dB (factor of 2) is commonly recommended. For safety-critical systems, 8-12 dB is preferred. Very high gain margins (>20 dB) may indicate an overly conservative (slow) design.

How do gain margin and phase margin relate?

Both are stability margins but measured differently. A system can have good phase margin but poor gain margin, or vice versa. Both should be adequate for robust stability. Typically, GM > 6 dB and PM > 30° are used together.

What if the system has no phase crossover?

If the open-loop phase never reaches -180° (as in a first-order system), the gain margin is infinite—the system is stable for any gain. This is a desirable property but uncommon in complex systems.

Ready to run the numbers?

Open Gain Margin Calculator