1
$\begingroup$

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?

$\endgroup$

2 Answers 2

7
$\begingroup$

-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

$\endgroup$
2
  • $\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
    Commented Nov 8, 2019 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
    Commented Nov 12, 2019 at 3:30
2
$\begingroup$

In your example inv(P) is not equal to [-1/6,1/3;1/6,2/3]. The problem is that before 6.1 version, Scilab was sometimes displaying very small numbers as zero. In Scilab 6.0.2 and older versions, you will see (using recursive extraction allow to see actual non-zero term) :

--> P=[-4,2;1,1]; inv(P)-[-1/6,1/3;1/6,2/3]
 ans  =

   0.   0.
   0.   0.

--> (inv(P)-[-1/6,1/3;1/6,2/3])(1,1)
 ans  =

  -2.776D-17

In Scilab 6.1 the display is fully explicit:

--> P=[-4,2;1,1]; inv(P)-[-1/6,1/3;1/6,2/3]
 ans  =

  -2.776D-17   0.
   0.          0.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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