method and system for non - linear modeling of physiological behavior , such as r - r intervals , in implantable devices , such as a rate responsive pacemakers , comprising a comprehensive modeling and optimization methodology based on fractional calculus and constrained finite horizon optimal control theory that allows for allows for fine - grain optimization of pacemaker response to heart rate variations ; and the theoretical basis on which a hardware implementation of the fractional optimal controller that can respond to changes in the heart rate dynamics . present invention describes a fractal approach to pacemaker control based on the constrained finite horizon optimal control problem . this is achieved by modeling the heart rate dynamics via fractional differential equations . also , by using calculus of variations , the invention describes how the constrained finite horizon optimal control problem can be reduced to solving a linear system of equations . finally , the invention describes the theoretical basis on which a hardware implementation become possible .