Science & engineering

Marine compass deviation-curve and heading-error calculator

Fitted deviation is added to compass heading to obtain magnetic heading; east-positive variation then gives true heading..

Your numbers

Numeric JSON array. Follow the displayed column labels and units; example data are synthetic.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A compass heading, magnetic heading and true heading refer to different north references. Compass deviation is the difference introduced by the vessel's compass environment, while variation connects magnetic north with true north for the relevant place and date. This calculator fits a declared deviation curve from supplied compass-swing observations and applies an explicitly signed variation.

THE FORMULADeviation=A+B sinC+C cosC+D sin2C+E cos2C; true=compass+deviation+variation.

A worked example

The prefilled example gives True heading degrees = 37. This demonstration uses supplied example data, not an approved vessel operating condition.

Good to know

Five-term least-squares deviation model versus COMPASS heading. East variation/deviation positive; magnetic=compass+deviation,true=magnetic+variation. Supplied swing only; no geomagnetic model or compass adjustment instruction.

Separate the three heading references

A compass heading, magnetic heading and true heading refer to different north references. Compass deviation is the difference introduced by the vessel's compass environment, while variation connects magnetic north with true north for the relevant place and date. This calculator fits a declared deviation curve from supplied compass-swing observations and applies an explicitly signed variation.

The fit is not a live magnetic-field service. Variation must come from a suitable dated source, and the deviation observations must represent the vessel condition being modeled. Treating either correction as a timeless property can give a plausible-looking heading that is nevertheless based on conditions no longer present aboard the vessel.

A compass swing can identify a sinusoidal deviation termC = 30°; deviation = 2°True = 30 + 2 + 5 = 37°
Scroll across to see the full diagram.
For deviation1+2sinC degrees, headingC30° gives deviation2°. With variation+5°, true heading is37°.

For a related reference calculation, see the Compass direction and bearing calculator.

Use one sign convention throughout

This page uses east-positive errors: magnetic heading equals compass heading plus deviation, and true heading equals magnetic heading plus variation. The final display is wrapped into a full circle only after the signed additions. Keeping the intermediate magnetic heading visible helps identify whether a sign or reference error entered at the compass or variation step.

Compass-swing rows give compass heading and observed signed deviation. A deviation of minus one degree should not be entered as positive 359 degrees without normalization. Although those angles represent the same wrapped direction, an ordinary regression would treat them as very different numerical errors and could distort the fitted harmonic coefficients dramatically.

The declared harmonic curve

The model is a constant term plus sine and cosine terms at heading frequency and twice heading frequency. Written in coefficients, deviation is A plus B sine C plus C-coefficient cosine C plus D sine twice C plus E cosine twice C. The heading C is in radians inside the trigonometric evaluation.

Five coefficients require at least five independent observations, but observation count alone does not guarantee a solvable fit. Poorly distributed or repeated headings can leave the design matrix rank deficient. A full-rank least-squares solution and residual diagnostic are therefore part of the calculation, rather than accepting every collection of five rows as an adequate compass swing.

A constant-deviation reference example

Choose eight compass headings spaced by 45 degrees around the circle and give each an observed deviation of positive two degrees. The exact fitted coefficients are A equal to two and the four harmonic coefficients equal to zero. Residuals vanish because the observations are exactly represented by the constant portion of the model.

At a compass heading of 100 degrees, the fitted deviation remains positive two, so magnetic heading is 102. With supplied east variation positive three degrees, true heading becomes 105. This synthetic case independently checks the regression's constant term and the two reference conversions without depending on a particular vessel's magnetic behavior.

Read coefficients with the residuals

A fitted coefficient is a parameter of this selected harmonic approximation, not a direct diagnosis of a named magnetic component. The residuals show where the observed swing differs from that approximation. A small residual on the entered headings can still coexist with unmeasured behavior between headings or under another loading, electrical or structural condition.

Compare residual size with the quality of the original observations rather than with the number of decimal places returned by the solver. A fitted curve can smooth observation noise, but it cannot repair a swing whose reference bearings or heading records were systematically biased. Retaining the observation table allows another reviewer to separate a fitting problem from an input-reference problem.

When a fitted curve should not be reused

The selected curve describes the conditions represented by the supplied observations. Changes to nearby magnetic equipment, electrical loads, structure or the vessel environment can make an old fit less representative. The calculation does not determine when those changes require a new compass assessment, nor does it approve a compass adjustment or replace the vessel's deviation card.

Extrapolation in heading is periodic in this model, but that periodicity should not be confused with evidence. A narrow cluster of swing headings may give an unstable full-circle fit even if a solver produces numbers. Adequate angular coverage and explicit rank or conditioning checks are more informative than hiding a weak fit behind a smooth plotted curve.

Report the reference and the conditions

Keep the swing date, observed reference, deviation signs, variation source and modeled vessel condition with the result. When sharing a converted heading, identify whether it is true, magnetic or compass rather than writing a bare degree value. The same number can mean a different direction when the north reference has changed.

This page is an educational harmonic fit and heading-conversion tool. It does not provide current variation, certify compass accuracy or authorize navigational use of a fitted correction. Actual navigation should use the vessel's approved information, appropriate observations and the relevant procedures, with the calculation serving as a transparent check of the stated corrections. Five-term least-squares deviation model versus COMPASS heading. East variation/deviation positive; magnetic=compass+deviation,true=magnetic+variation. Supplied swing only; no geomagnetic model or compass adjustment instruction.

A few questions, answered

What does positive deviation mean here?

It is east-positive: add deviation to compass heading to obtain magnetic heading, then add east-positive variation to obtain true heading.

Does the page fetch magnetic variation for my current position?

No. Variation is a supplied dated input, independent of the fitted vessel deviation curve.

Are five swing observations always enough?

No. They must also produce a full-rank harmonic design; repeated or poorly distributed headings can be insufficient.

Does a small fitting residual certify the compass?

No. It describes agreement with the entered swing data and selected model, not accuracy under every heading or vessel condition.

Find your calculator

Start typing to explore the library.