I've used the linearalgebra package in the past, and I think I understand it, but, I'm getting divide by zero
Here are my equations:
-70x + 45y + 60z = 0
20x - 120y + 40z = 0
50x + 75y - 100z = 0
1x + 1y + 1z = 18500
The system has a unique solution:
x = 333000/41, y = 148000/41, z = 277500/41
Am I not expressing A and b properly?
% package require math::linearalgebra
1.0.1
% set A {{-70 45 60} {20 -120 40} {50 75 -100} {1 1 1}}
{-70 45 60} {20 -120 40} {50 75 -100} {1 1 1}
% set b "0 0 0 18500"
0 0 0 18500
% math::linearalgebra::solveGauss $A $b
divide by zero
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh, this could be a problem with integer divide versus floating-point divides. I will check this!
In the meantime, what happens if you change the numbers into floating-point numbers? -70 -> -70.0 etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oops, I should have looked better. This has nothing to do with integer divides.
You have four equations and only three variables. One of the equations is superfluous.
Try:
set A {{20 -120 40} {50 75 -100} {1 1 1}}
set b {0 0 18500}
puts
(If you scale by 41, you will get (almost) the numerators you posted)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've used the linearalgebra package in the past, and I think I understand it, but, I'm getting divide by zero
Here are my equations:
-70x + 45y + 60z = 0
20x - 120y + 40z = 0
50x + 75y - 100z = 0
1x + 1y + 1z = 18500
The system has a unique solution:
x = 333000/41, y = 148000/41, z = 277500/41
Am I not expressing A and b properly?
% package require math::linearalgebra
1.0.1
% set A {{-70 45 60} {20 -120 40} {50 75 -100} {1 1 1}}
{-70 45 60} {20 -120 40} {50 75 -100} {1 1 1}
% set b "0 0 0 18500"
0 0 0 18500
% math::linearalgebra::solveGauss $A $b
divide by zero
Oh, this could be a problem with integer divide versus floating-point divides. I will check this!
In the meantime, what happens if you change the numbers into floating-point numbers? -70 -> -70.0 etc.
Oops, I should have looked better. This has nothing to do with integer divides.
You have four equations and only three variables. One of the equations is superfluous.
Try:
set A {{20 -120 40} {50 75 -100} {1 1 1}}
set b {0 0 18500}
puts
(If you scale by 41, you will get (almost) the numerators you posted)
The solveGauss procedure should actually check that the matrix it gets is square.
ah! you are right. the equations solve it I drop the 3rd equation. the first three equations are not independent