def TRMinv(m,a,b):
    WARN = True    # Warn, rather than stop if I encounter a NaN...
    """
     Calculate applied field from TRM using tanh relationship
     TRMinv(m)=(1/b)*atanh(m/a)
    """
    if float(a)==0:
        print('ERROR: TRMinv: a==0.')
        if not WARN : sys.exit()
    if float(b)==0:
        print('ERROR: TRMinv: b==0.')
        if not WARN : sys.exit()
    x = (old_div(float(m), float(a)))
    if (1-x)<=0:
         print('ERROR:  TRMinv: (1-x)==0.')
         return -1
    if not WARN : sys.exit()
    f = (old_div(1.,float(b))) * 0.5 * math.log (old_div((1+x), (1-x)))
    return float(f)