Solve simultaneous equations in an instant using Python

Solve simultaneous equations using Sympy on IPython

・ Xyz = -234 ・ X + y + z = 20 ・ 5x – y + 2z = 85

(Environment: Ubuntu12.04LTS)

IPython installation

$ sudo apt-get install ipython-notebook

Install other related science and technology calculation libraries

$ sudo apt-get install python-matplotlib python-scipy python-pandas python-sympy python-nose

Launch IPython

$ ipython

Output the solution of simultaneous equations

In the IPython shell, type:

from sympy import *
x, y, z = symbols('x y z')
init_printing()
solve([x * y * z + 234, x + y + z - 20, 5 * x - y + 2 * z - 85], [x, y, z])

For the formula xyz = -234, write x * y * x + 234.

Answer output result

When init_printing () is described (the image is divided into 3 for layout reasons): sympy2_1.jpg sympy2_2.jpg sympy2_3.jpg

If you didn't write init_printing ():

[(-9*17**(1/2)/4 + 39/4, -9*17**(1/2)/4 - 21/4, 31/2 + 9*17**(1/2)/2),
 (13, -2, 9), (9*17**(1/2)/4 + 39/4, -21/4 + 9*17**(1/2)/4, -9*17**(1/2)/2 + 31/2)]

How to calculate online without building an environment

Go to the following website. ・ SymPy Live http://live.sympy.org/

You can use Sympy to perform calculations from the console just like iPython.

Recommended Posts

Solve simultaneous equations in an instant using Python
Solve ordinary differential equations in Python
Solve ABC168D in Python
Solve ABC167-D in Python
Let's solve simultaneous linear equations with Python sympy!
Solve ABC146-C in Python
Solve ABC098-C in Python
Solve ABC169 in Python
Solve ABC160-E in Python
Solve simultaneous ordinary differential equations with Python and SymPy.
Non-linear simultaneous equations can be easily solved in Python.
[Python] Create an infrastructure diagram in 3 minutes using diagrams
[Python] Solve equations with sympy
Quicksort an array in Python 3
Solve ABC176 E in Python
Solve Wooldridge exercises in Python
Solve ABC175 D in Python
Solve optimization problems in Python
Translate using googletrans in Python
Using Python mode in Processing
[Circuit x Python] How to solve circuit equations symbolically using sympy
GUI programming in Python using Appjar
Precautions when using pit in Python
Write an HTTP / 2 server in Python
How to solve simultaneous linear equations
Solve Atcoder ABC169 A-D in Python
Try using LevelDB in Python (plyvel)
Develop an investment algorithm in Python 2
Using global variables in python functions
Solve ABC036 A ~ C in Python
Let's see using input in python
Infinite product in Python (using functools)
Edit videos in Python using MoviePy
Solve ABC037 A ~ C in Python
Python in is also an operator
Try using Leap Motion in Python
Depth-first search using stack in Python
An alternative to `pause` in Python
When using regular expressions in Python
GUI creation in python using tkinter 2
Build and try an OpenCV & Python environment in minutes using Docker
Notes using cChardet and python3-chardet in Python 3.3.1.
Solve ABC175 A, B, C in Python
Try using the Wunderlist API in Python
GUI creation in python using tkinter part 1
Get Suica balance in Python (using libpafe)
(Bad) practice of using this in Python
Slowly hash passwords using bcrypt in Python
Try using the Kraken API in Python
Using venv in Windows + Docker environment [Python]
ABC 157 D --Solve Friend Suggestions in Python!
[FX] Hit oanda-API in Python using Docker
Tweet using the Twitter API in Python
[Python] [Windows] Serial communication in Python using DLL
I tried using Bayesian Optimization in Python
Log in to Slack using requests in Python
Get Youtube data in Python using Youtube Data API
Using physical constants in Python scipy.constants ~ constants e ~
Build an application with Clean Architecture while using DI + mock in Python
Scraping a website using JavaScript in Python
Develop slack bot in python using chat.postMessage