grzegorzmazur / yacas

Computer calculations made easy
http://www.yacas.org
GNU Lesser General Public License v2.1
120 stars 23 forks source link

I was having issues with `det` in `Ryacas` so I decided to take a look at `yacas`. I am getting inconsistent results. #324

Closed grzegorzmazur closed 3 years ago

grzegorzmazur commented 3 years ago

I was having issues with det in Ryacas so I decided to take a look at yacas. I am getting inconsistent results.

// SYMBOLIC

A := {{a, b, c}, {d, e, f}, {g, h, i}};
Determinant(A);

// Returns 3*a*e-a*f*h+c*d*h-3*b*d+b*f*g-c*e*g on my machine.
// Based on Wikipedia (https://en.wikipedia.org/wiki/Determinant) it should return
// a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h.

// NUMERIC

B := {{1, 0.50, 0.25}, {0.50, 1, 0.75}, {0.25, 0.75, 1}};
N(Determinant(B));

// Returns 0.3125 on my machine.

// TESTING RESULT OF SYMBOLIC

a := 1;
b := 0.50;
c := 0.25;
d := 0.50;
e := 1;
f := 0.75;
g := 0.25;
h := 0.75;
i := 1;
C := {{a, b, c}, {d, e, f}, {g, h, i}};

// `N(Determinant(C))` returns 0.3125 which is the same as the numeric example
// but not the same as the symbolic example.

// USING SYMBOLIC RESULT WITH NUMBER

3*a*e - a*f*h + c*d*h - 3*b*d + b*f*g - c*e*g;

// Returns 1.8125 which is not equal to 0.3125

Originally posted by @jeksterslab in https://github.com/r-cas/ryacas/issues/55#issuecomment-772489559