Get a system of equations with Python

Asked 2 years ago, Updated 2 years ago, 16 views

I'd like to make a program with Python to solve the problem of a coalition equation, but I'm a beginner, so I'd appreciate it if you could show me an example of the program <

python

2022-09-22 20:07

2 Answers

You can do it as below.

from sympy import Symbol, solve, Eq

x = Symbol('x')
y = Symbol('y')

e1 = Eq(2*y, 4*x - 5)
e2 = Eq(3*y, 4*x + 6)

solve([e1, e2], x, y)

Out: {x:27/4, y:11}


2022-09-22 20:07

Python uses numpy and sympy a lot. http://www.sympy.org/en/index.html

from sympy import Symbol, solve

x = Symbol('x')
eq = 3 * x - 9
solve(eq)

Out: [3] 


2022-09-22 20:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.