Menu

help with math::linearalgebra

Help
2010-10-09
2013-05-30
  • nomorecaddy

    nomorecaddy - 2010-10-09

    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

     
  • Arjen Markus

    Arjen Markus - 2010-10-11

    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.

     
  • Arjen Markus

    Arjen Markus - 2010-10-18

    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)

     
  • Arjen Markus

    Arjen Markus - 2010-10-18

    The solveGauss procedure should actually check that the matrix it gets is square.

     
  • nomorecaddy

    nomorecaddy - 2010-10-18

    ah!  you are right.  the equations solve it I drop the 3rd equation.  the first three equations are not independent

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.