FA-69281 / Tide and marine navigation tables / Open access
Compass variation and deviation: True to compass adds the corrections · case 01
Compass courses derived from true are off by twice the error.
ROOT CAUSE
The downward branch adds rather than subtracts the corrections.
VERIFIED REPAIR
Subtract corrections when converting toward compass.
Unsuccessful approach: Subtracting the forward slice corr[a:b] is empty for downward conversions.
Case contract
Input [value, frm, to, var, dev] with frm/to in C (compass), M (magnetic), T (true); var and dev like "3.5W"/"2E" (east positive). M=C+dev, T=M+var; converting downward subtracts. Return [value mod 360 rounded 1, total compass error dev+var as "x.xE"/"x.xW" or "0"].
Why this case matters
Tide tables and passage plans turn published predictions into go/no-go decisions about depth, clearance and timing.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
val,frm,to,var,dev=x
def sg(s):
v=float(s[:-1])
return v if s[-1]=='E' else -v
lvl={'C':0,'M':1,'T':2}
corr=[sg(dev),sg(var)]
a,b=lvl[frm],lvl[to]
if b>a: val+=sum(corr[a:b])
else: val+=sum(corr[b:a])
e=sum(corr)
err='0' if e==0 else '%.1f%s'%(abs(e),'E' if e>0 else 'W')
return [round(val%360,1),err]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W'])], [('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W']), ('compass variation and deviation [90, "T", "T", "3E", "3W"]', [90, 'T', 'T', '3E', '3W'], [90, '0']), ('compass variation and deviation [270.5, "C", "T", "12.5E", "3.5E"]', [270.5, 'C', 'T', '12.5E', '3.5E'], [286.5, '16.0E']), ('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E'])], [('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W']), ('compass variation and deviation [90, "T", "T", "3E", "3W"]', [90, 'T', 'T', '3E', '3W'], [90, '0']), ('compass variation and deviation [270.5, "C", "T", "12.5E", "3.5E"]', [270.5, 'C', 'T', '12.5E', '3.5E'], [286.5, '16.0E']), ('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E']), ('compass variation and deviation [45, "C", "T", "3E", "3W"]', [45, 'C', 'T', '3E', '3W'], [45.0, '0']), ('compass variation and deviation [180, "M", "T", "0E", "2W"]', [180, 'M', 'T', '0E', '2W'], [180.0, '2.0W'])], [('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E']), ('compass variation and deviation [45, "C", "T", "3E", "3W"]', [45, 'C', 'T', '3E', '3W'], [45.0, '0']), ('compass variation and deviation [180, "M", "T", "0E", "2W"]', [180, 'M', 'T', '0E', '2W'], [180.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W'])], [('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W'])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| compass variation and deviation [100, "T", "C", "4W", "2E"] | [98.0, '2.0W'] | [102.0, '2.0W'] | Failed |
| compass variation and deviation [100, "C", "T", "4W", "2E"] | [98.0, '2.0W'] | [98.0, '2.0W'] | Passed |
| compass variation and deviation [355, "C", "M", "3W", "6E"] | [1.0, '3.0E'] | [1.0, '3.0E'] | Passed |
| compass variation and deviation [5, "T", "M", "7W", "1W"] | [358.0, '8.0W'] | [12.0, '8.0W'] | Failed |
| compass variation and deviation [5, "M", "T", "7W", "1W"] | [358.0, '8.0W'] | [358.0, '8.0W'] | Passed |
| compass variation and deviation [200, "M", "C", "0.5E", "1.5W"] | [198.5, '1.0W'] | [201.5, '1.0W'] | Failed |
| compass variation and deviation [200, "C", "M", "0.5E", "1.5W"] | [198.5, '1.0W'] | [198.5, '1.0W'] | Passed |
SHA-256 / b31b4ca279935558dc10c815ecb16099205fc749bb7f5a27f5a91bced68a4abd
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
val,frm,to,var,dev=x
def sg(s):
v=float(s[:-1])
return v if s[-1]=='E' else -v
lvl={'C':0,'M':1,'T':2}
corr=[sg(dev),sg(var)]
a,b=lvl[frm],lvl[to]
if b>a: val+=sum(corr[a:b])
else: val-=sum(corr[a:b])
e=sum(corr)
err='0' if e==0 else '%.1f%s'%(abs(e),'E' if e>0 else 'W')
return [round(val%360,1),err]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W'])], [('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W']), ('compass variation and deviation [90, "T", "T", "3E", "3W"]', [90, 'T', 'T', '3E', '3W'], [90, '0']), ('compass variation and deviation [270.5, "C", "T", "12.5E", "3.5E"]', [270.5, 'C', 'T', '12.5E', '3.5E'], [286.5, '16.0E']), ('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E'])], [('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W']), ('compass variation and deviation [90, "T", "T", "3E", "3W"]', [90, 'T', 'T', '3E', '3W'], [90, '0']), ('compass variation and deviation [270.5, "C", "T", "12.5E", "3.5E"]', [270.5, 'C', 'T', '12.5E', '3.5E'], [286.5, '16.0E']), ('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E']), ('compass variation and deviation [45, "C", "T", "3E", "3W"]', [45, 'C', 'T', '3E', '3W'], [45.0, '0']), ('compass variation and deviation [180, "M", "T", "0E", "2W"]', [180, 'M', 'T', '0E', '2W'], [180.0, '2.0W'])], [('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E']), ('compass variation and deviation [45, "C", "T", "3E", "3W"]', [45, 'C', 'T', '3E', '3W'], [45.0, '0']), ('compass variation and deviation [180, "M", "T", "0E", "2W"]', [180, 'M', 'T', '0E', '2W'], [180.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W'])], [('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W'])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| compass variation and deviation [100, "T", "C", "4W", "2E"] | [100, '2.0W'] | [102.0, '2.0W'] | Failed |
| compass variation and deviation [100, "C", "T", "4W", "2E"] | [98.0, '2.0W'] | [98.0, '2.0W'] | Passed |
| compass variation and deviation [355, "C", "M", "3W", "6E"] | [1.0, '3.0E'] | [1.0, '3.0E'] | Passed |
| compass variation and deviation [5, "T", "M", "7W", "1W"] | [5, '8.0W'] | [12.0, '8.0W'] | Failed |
| compass variation and deviation [5, "M", "T", "7W", "1W"] | [358.0, '8.0W'] | [358.0, '8.0W'] | Passed |
| compass variation and deviation [200, "M", "C", "0.5E", "1.5W"] | [200, '1.0W'] | [201.5, '1.0W'] | Failed |
| compass variation and deviation [200, "C", "M", "0.5E", "1.5W"] | [198.5, '1.0W'] | [198.5, '1.0W'] | Passed |
SHA-256 / a1a0ae61d29639a4f9dbeb4184ae2a9680121f7d45eba35db87f970764deca92
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
val,frm,to,var,dev=x
def sg(s):
v=float(s[:-1])
return v if s[-1]=='E' else -v
lvl={'C':0,'M':1,'T':2}
corr=[sg(dev),sg(var)]
a,b=lvl[frm],lvl[to]
if b>a: val+=sum(corr[a:b])
else: val-=sum(corr[b:a])
e=sum(corr)
err='0' if e==0 else '%.1f%s'%(abs(e),'E' if e>0 else 'W')
return [round(val%360,1),err]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W'])], [('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W']), ('compass variation and deviation [90, "T", "T", "3E", "3W"]', [90, 'T', 'T', '3E', '3W'], [90, '0']), ('compass variation and deviation [270.5, "C", "T", "12.5E", "3.5E"]', [270.5, 'C', 'T', '12.5E', '3.5E'], [286.5, '16.0E']), ('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E'])], [('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W']), ('compass variation and deviation [90, "T", "T", "3E", "3W"]', [90, 'T', 'T', '3E', '3W'], [90, '0']), ('compass variation and deviation [270.5, "C", "T", "12.5E", "3.5E"]', [270.5, 'C', 'T', '12.5E', '3.5E'], [286.5, '16.0E']), ('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E']), ('compass variation and deviation [45, "C", "T", "3E", "3W"]', [45, 'C', 'T', '3E', '3W'], [45.0, '0']), ('compass variation and deviation [180, "M", "T", "0E", "2W"]', [180, 'M', 'T', '0E', '2W'], [180.0, '2.0W'])], [('compass variation and deviation [1, "T", "C", "2E", "3E"]', [1, 'T', 'C', '2E', '3E'], [356.0, '5.0E']), ('compass variation and deviation [45, "C", "T", "3E", "3W"]', [45, 'C', 'T', '3E', '3W'], [45.0, '0']), ('compass variation and deviation [180, "M", "T", "0E", "2W"]', [180, 'M', 'T', '0E', '2W'], [180.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W'])], [('compass variation and deviation [100, "T", "C", "4W", "2E"]', [100, 'T', 'C', '4W', '2E'], [102.0, '2.0W']), ('compass variation and deviation [100, "C", "T", "4W", "2E"]', [100, 'C', 'T', '4W', '2E'], [98.0, '2.0W']), ('compass variation and deviation [355, "C", "M", "3W", "6E"]', [355, 'C', 'M', '3W', '6E'], [1.0, '3.0E']), ('compass variation and deviation [5, "T", "M", "7W", "1W"]', [5, 'T', 'M', '7W', '1W'], [12.0, '8.0W']), ('compass variation and deviation [5, "M", "T", "7W", "1W"]', [5, 'M', 'T', '7W', '1W'], [358.0, '8.0W']), ('compass variation and deviation [200, "M", "C", "0.5E", "1.5W"]', [200, 'M', 'C', '0.5E', '1.5W'], [201.5, '1.0W']), ('compass variation and deviation [200, "C", "M", "0.5E", "1.5W"]', [200, 'C', 'M', '0.5E', '1.5W'], [198.5, '1.0W'])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| compass variation and deviation [100, "T", "C", "4W", "2E"] | [102.0, '2.0W'] | [102.0, '2.0W'] | Passed |
| compass variation and deviation [100, "C", "T", "4W", "2E"] | [98.0, '2.0W'] | [98.0, '2.0W'] | Passed |
| compass variation and deviation [355, "C", "M", "3W", "6E"] | [1.0, '3.0E'] | [1.0, '3.0E'] | Passed |
| compass variation and deviation [5, "T", "M", "7W", "1W"] | [12.0, '8.0W'] | [12.0, '8.0W'] | Passed |
| compass variation and deviation [5, "M", "T", "7W", "1W"] | [358.0, '8.0W'] | [358.0, '8.0W'] | Passed |
| compass variation and deviation [200, "M", "C", "0.5E", "1.5W"] | [201.5, '1.0W'] | [201.5, '1.0W'] | Passed |
| compass variation and deviation [200, "C", "M", "0.5E", "1.5W"] | [198.5, '1.0W'] | [198.5, '1.0W'] | Passed |
SHA-256 / 0b95086fe7ae7ea543a043d727e3101c1f9c0deb32eecbe563982c8f5a8d408b
Verification & scope
A deterministic toy model with stipulated rules and constants; not certified hydrographic software or a substitute for official tide tables. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:48:10.001490+00:00.
Case digest / fd4394155b7e3564e41fcee0812cde93762b8dc07b786dd533965fbbf93a217d