I entered an instruction to calculate the coordinates of a vector after a change of basis in order to repeat it many times with various vectors.

X0=[1;1/2] is a set of coordinates in the initial basis and P=[-4,2;1,1] is the new basis expressed in the initial one.

When I compute P^(-1)*X0 I get :

ans = [-2.776D-17 ; 0.5]

The problem is, when I work it out by hand, I get P^(-1)=[-1/6,1/3;1/6,2/3] which Scilab agrees with, and then the first coordinate of P^(-1)*X0 should be 0.

So I attempted to calculate that first coordinate manually with Scilab, by entering (-1/6)*1+(1/3)*(1/2) which indeed gave me 0 as an answer.

I tried restarting Scilab which didn't resolve the issue, and I'm not a computer expert, anyone seen this happen before?


-2.776D-17 equals $-2.776\cdot 10^{-17}$, which is indeed very small and for all practical purposes is zero. I think scilab is OK

  • $\begingroup$ Fair point. It still intrigues me as to why -(1/6)*1+(1/3)*(1/2) still comes out as an actual 0, and not -2.776D-17. As if the internal "black box" approximations of rational numbers weren't the same in both cases. $\endgroup$ – James Well Nov 8 '19 at 18:03
  • $\begingroup$ @JamesWell it's likely that the inverse operation has some error and that it doesn't return exactly 1/6 and 1/3. From pure floating point math with those values, you should get zero exactly. $\endgroup$ – Tyberius Nov 12 '19 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.