in reply to How would you solve a user-inputted simple one-variable Linear Equation

I think the traditional approach of implementing/solving linear equations is to convert them into matrix form and then repeatedly applying Gaussian Elimination until you solve the system or determine that it has no solution.

The easiest way of doing so is to either link to a solver library (maybe PDL has an equation system solver).

  • Comment on Re: How would you solve a user-inputted simple one-variable Linear Equation

Replies are listed 'Best First'.
Re^2: How would you solve a user-inputted simple one-variable Linear Equation
by etj (Priest) on May 20, 2022 at 14:37 UTC
Re^2: How would you solve a user-inputted simple one-variable Linear Equation
by nat47 (Sexton) on Apr 25, 2015 at 16:52 UTC
    Gaussian Elimination on a single variable? Okay...

    I don't want to use a pre-made library, I would like to do this all with my 'own' code, so to speak. You used the word "either" in your last sentence, but only gave one thing? Thanks for the response!

      Sorry, the other part of the "either" would be to call any linear solver program yourself.

      If you only have one linear equation, the solution is to simply restate the formula in the form

      a*x +b = 0

      From that, the solution is immediately clear.