  We employ computer simulations and thermodynamic integration to analyse the
effects of bending rigidity and slit confinement on the free energy cost of
tying knots, $\Delta F_{\rm knotting}$, on polymer chains under tension. A
tension-dependent, non-zero optimal stiffness $\kappa_{\rm min}$ exists, for
which $\Delta F_{\rm knotting}$ is minimal. For a polymer chain with several
stiffness domains, each containing a large amount of monomers, the domain with
stiffness $\kappa_{\rm min}$ will be preferred by the knot. A {\it local}
analysis of the bending in the interior of the knot reveals that local
stretching of chains at the braid region is responsible for the fact that the
tension-dependent optimal stiffness has a non-zero value. The reduction in
$\Delta F_{\rm knotting}$ for a chain with optimal stiffness relative to the
flexible chain can be enhanced by tuning the slit width of the 2D confinement
and increasing the knot complexity. The optimal stiffness itself is independent
of the knot types we considered, while confinement shifts it towards lower
values.
