0

For example, I have the following system of equations (they can be non-linear):
A + B = C
C * D = E

I want to enter some values for the variables (e.g. A = 1, B = 2, D = 3) and get the result for other variables (in this example, E = 9), and I can change the variables and instantly get the new result (e.g. I say A = 2, and I want to get E = 12 instantly)

samtestsam
  • 61
  • 5
  • 1
    Please, look at : https://stackoverflow.com/questions/10499941/how-can-i-solve-equations-in-python (or google your request). – Jona Feb 10 '20 at 09:41
  • @Jona thanks, I googled, but usually the questions are about system of linear equations – samtestsam Feb 10 '20 at 09:45
  • 3
    Hmm, Python is a *programming language*. In that sense it can be used to solve any deterministic question, provide someone writes the appropriate code. If the question is *does a library exists for that?*; then it is explicitely off topic on SO (please read [ask]). As a hint, scipy could be an interesting starting point. – Serge Ballesta Feb 10 '20 at 09:51
  • The best way so far to solve Python equation is using ```Sympy```. Check out https://www.sympy.org/en/index.html – Swati Srivastava Feb 10 '20 at 10:10

1 Answers1

1

You could use z3

#!/usr/bin/python3

from  z3 import *
A = Real('A')
B = Real('B')
C = Real('C')
D = Real('D')
E = Real('E')

A = 1
B = 2
D = 3

solve(A + B == C, C * D == E)
Jina Jita
  • 136
  • 1
  • 3