# H. Numerical calculation of the FDC

The calculation of the FDC has to be performed numerically due to the length of the DNA sequence. The computation of the DNA energy (Eq. 3.17) is a simple sum of terms that extends over all the base pairs of the molecular construct. So this large summation must be done numerically. Apart from that, the exponential terms that enter the partition function have a wide range of orders of magnitude and they must be treated correctly.

The partition function is a function of the distance (i.e., the total extension) , which is a variable that has to be discretized in order to calculate the value of at each position. The distance is divided into equidistant points separated by a distance (see Fig. H.1). A value of  nm is enough for our calculations. The details of the calculated FDC are missed for higher values of and lower values of it do not improve the calculation.

Now, for each value of we have to find the minimum of Eq. 3.22 with respect to . In order to do this, we have to solve Eq. 3.23 for all values of according to , compute the energies and get the value that minimizes the energy at fixed . Equation 3.23 is a trascendental equation and it can be solved numerically by using the Newton's method. This method gives the equilibrium force of the system after few interations (no more than 10 to obtain a numerical estimation of with a relative error smaller than 10) of the following expression

 (H.1)

where and are the previous and the posterior values obtained from the iteration, respectively; is Eq. 3.23 evaluated at and ; and is its derivative with respect to . An initial guess of ensures the convergence of the solution because the first and second derivatives of function have positive values for all values of , which fulfills the Newton's method conditions (see Fig. H.2).

Once we have the combination of values () we can now calculate the minimum energy according to Eq. 3.22. The discretized Eq. 3.27 can be written as

 (H.2)

where the partition functions have to be calculated according to

 (H.3)

The problem with this equation is that the values of become larger as the value of increases. When these energies are introduced in the exponential, the value of can be orders of magnitude smaller than 1. Therefore the quotient of Eq. H.2 is numerically less accurate for large values of . The result is a loss of accuracy in the calculation of the FDC as increases.

This problem can be fixed by taking advantage of the calculated value of . The idea consists in rewriting the partition function with all the energies referred to this state. So we have,

 (H.4)

where

 (H.5)

is the partition function calculated with an energy offset given by the state of minimum energy at fixed . Equation H.4 can be introduced into Eq. H.2 to obtain
 (H.6)

where , , and can be easily calculated numerically.

To sum up, the numerical calculation of the FDC requires the following steps,

1. Discretize the distance with equidistant values .
2. For each value of , calculate the energies for all the values of by solving Eq. H.1.
3. Among the previously calculated energies, find the value of that minimizes the energy for each value of . This energy is called .
4. For each value of , calculate according to Eq. H.5
5. For each value of , calculate according to Eq. H.6.

JM Huguet 2014-02-12