code: def second_derivative_5(var, key):
      '''5 point 2nd derivative'''
      global derivative_data
      import mavutil
      tnow = mavutil.mavfile_global.timestamp
  
      if not key in derivative_data:
          derivative_data[key] = (tnow, [var]*5)
          return 0
      (last_time, data) = derivative_data[key]
      data.pop(0)
      data.append(var)
      derivative_data[key] = (tnow, data)
      h = (tnow - last_time)
      # N=5 2nd derivative from
      # http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/smooth-low-noise-differentiators/
      ret = ((data[4] + data[0]) - 2*data[2]) / (4*h**2)
      return ref second_derivative_5(var, key):
      '''5 point 2nd derivative'''
      global derivative_data
      import mavutil
      tnow = mavutil.mavfile_global.timestamp
  
      if not key in derivative_data:
          derivative_data[key] = (tnow, [var]*5)
          return 0
      (last_time, data) = derivative_data[key]
      data.pop(0)
      data.append(var)
      derivative_data[key] = (tnow, data)
      h = (tnow - last_time)
      # N=5 2nd derivative from
      # http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/smooth-low-noise-differentiators/
      ret = ((data[4] + data[0]) - 2*data[2]) / (4*h**2)
      return ret
docs: 5 point 2nd derivative