Skip to main content Skip to navigation

Software support forum

Software support forum accumulating errors in python

You need to be logged in to post in this topic.
  1. I have an optimisation over a vector that I have written in python. I begin my computing the cost function of the vector. To do this I take the vector's outer product and apply a unitary transformation, this is the time evolved state. From the time evolved state I calculate another another, the quantum fisher information matrix (QFIM). The trace of the inverse of the QFIM is the cost function I am trying to minimise.

    When I calculate the cost function in isolation, the value is accurate. However, when I perform the optimisation I naturally have to compute this many times. The error occurs in the calculation of the time evolved state. This problem confuses me because these errors don't occur whenever I calculate the final state on its own and only after several iterations of the optimisation. Once errors start, they begin small, on the eighth decimal place, but then appear to get worse. I have looked online and couldn't find anything pertinent to this problem. I can also obviously upload code if this isn't a known problem and would be useful.

    Any help appreciated, thanks in advanced,


  2. Sadly there's lots of ways that you can get propagating errors in algorithms so we're going to have to try and work out a method of attack. I've never worked in this area myself, and I'm a bit confused by some of what you're saying so I just want to check that I'm understanding the method that you're using

    1. You start with an initial state vector
    2. You take the outer product of this vector (with a trial vector? and you then minimize your cost function subject to this trial vector?) to get a matrix
    3. You now apply a unitary transform to this matrix
    4. You then calculate the cost function and then repeat?
    5. It seems that you started with a vector and then end up with a matrix?

    My problem is that I don't see how you are advancing your system in time iteratively becuase unless I'm misunderstanding what you're doing there's a missing step because you are starting with a vector and then producing a matrix. Since the accumulation of errors is going to be related to this iterative process I'm going to have to understand it a bit better to comment fully.

    I'm sorry to have to request more information, but while there are a few rules of thumb (try to keep all values of the same order, never take differences of numbers that are orders of magnitude different, always calculate a value once and use it twice rather than calculate it twice etc.) the exact cause of numerical error tends to be specific to the algorithm being used.

  3. Ah yeah, sorry I wasn't clear. I have written a genetic algorithm, so once I calculate the final evolved evolved state and cost function, I use the cost function of each respective starting vector to update them for the next itteration. The update weights each state by the inverse of the cost function. Then two vectors are chosen are random given this weighting, the two chosen vectors are then "spliced" together at a random point in the vector. Then with some small probability a random mutation is made on some of the vector indexes. Each new vector is re-normalised then the process starts over again. If I sitll haven't explained myself well, I am working on some well presented latex notes.

    Thank you for these key things to look out for, I've been going through my code and I do have at least one instance of calculating the same thing twice, I'm fixing this and will check for the other potential issues.

    Thank you for the help