Home:ALL Converter>Is there a way to solve any linear equation and system of linear equations all in one?

Is there a way to solve any linear equation and system of linear equations all in one?

Ask Time:2021-02-25T07:02:43         Author:SublimeCosmo

Json Formatter

Note: I made this a while ago and have learned a lot more since then, enough to understand why what I was asking for was unrealistic. I also should have done more research into sympy before asking this question.

I want to create a program where you enter a linear equation or system of linear equations as a string and in return you get the value of the variable(s) you entered, like so:

equation = input('Expression: ')
# Code to solve your linear equation here
print(answer)

Just to be clear, I want to be able to solve things like x+5=10, or things like 2x+3y=29, and get an output that looks something like "5", or "4, 7" respectively.

I've tried searching multiple websites and some stack overflow questions, but all I've come up with are ways to solve systems of linear equations like 2x+3y=29 using numpy or ways to solve normal linear equations like x+5=10 but none that can do both.

Here's a list of 3 answers I found and why they didn't help:

  1. https://www.mybluelinux.com/how-solve-any-linear-equation-in-python/
    • Offers a solution to solve normal linear equations, but cannot solve systems of linear equations
  2. https://stackabuse.com/solving-systems-of-linear-equations-with-pythons-numpy/
    • Solves systems of linear equations, but can't solve linear equations like x+5=10
  3. Is there a python module to solve linear equations?
    • Same reason as 2, most answers suggested NumPy, and the other answers there didn't solve my problem either.

I also searched some other websites and stack overflow questions, but they didn't work either for the same reasons as the 3 examples I listed.

Author:SublimeCosmo,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/66360063/is-there-a-way-to-solve-any-linear-equation-and-system-of-linear-equations-all-i
yy