Determine if a vector is no longer changing

78 Views Asked by At

How can a vector be determined that it hasnt changed since the last iteration of a calculation?

Say I have a vector $i$ that looks like:

$$\left[ \begin{array}{x} 0.1201 \\ 0.2777 \\ 0.1004 \\ \end{array} \right]$$

And in running the same calculation yield a vector $j$ that looks like:

$$\left[ \begin{array}{x} 0.1098 \\ 0.2789 \\ 0.1010 \\ \end{array} \right]$$

And then a third time a vector $k$:

$$\left[ \begin{array}{x} 0.1098 \\ 0.2789 \\ 0.1006 \\ \end{array} \right]$$

Now there is no real pattern here, but I want to be able to determine when the vectors elements have stopped changing by a certain precision such as $1e-4$ or something. Do I have to compare each element in the current vector to the previous one? Or is taking the magnitude of the vector and comparing it to the previous magnitude viable?

1

There are 1 best solutions below

2
On

You cannot just compare the magnitudes! E.g. $(1,0)$ and $(0,1)$ have the same magnitude. To ensure that the vectors are sufficiently "equal", you indeed have to compare all components.

You can do this

  • directly by checking $|v_i^{t}-v_i^{t+1}|<10^{-4}$ for all $i=1,2,3$, or
  • indirectly by computing the magnitude $\|v^t-v^{t+1}\|$ and checking whether this one is smaller than e.g. $10^{-4}$.

Both approaches differ slightly in when exactly you consider the vectors non-changing, but this should make no difference in practice when your allowed error (here $10^{-4}$) is sufficiently small.