  The notion of positive realness for linear time-invariant (LTI) dynamical
systems, equivalent to passivity, is one of the oldest in system and control
theory. In this paper, we consider the problem of finding the nearest
positive-real (PR) system to a non PR system: given an LTI control system
defined by $E \dot{x}=Ax+Bu$ and $y=Cx+Du$, minimize the Frobenius norm of
$(\Delta_E,\Delta_A,\Delta_B,\Delta_C,\Delta_D)$ such that
$(E+\Delta_E,A+\Delta_A,B+\Delta_B,C+\Delta_C,D+\Delta_D)$ is a PR system. We
first show that a system is extended strictly PR if and only if it can be
written as a strict port-Hamiltonian system. This allows us to reformulate the
nearest PR system problem into an optimization problem with a simple convex
feasible set. We then use a fast gradient method to obtain a nearby PR system
to a given non PR system, and illustrate the behavior of our algorithm on
several examples. This is, to the best of our knowledge, the first algorithm
that computes a nearby PR system to a given non PR system that (i) is not based
on the spectral properties of related Hamiltonian matrices or pencils, (ii)
allows to perturb all matrices $(E,A,B,C,D)$ describing the system, and (iii)
does not make any assumption on the original given system.
