0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

paizaでsympy その2

Last updated at Posted at 2019-01-24

概要

sympyが、魔法なので、paizaで、やってみた。
練習問題、やってみた。

問題1

8x – 4 = 9x + 1
4x^2 = 100
3x^2 - 7x + 4 = 0
2x^2 + 4x = 48
5x^2 - 2x - 3 = 0
5x^2 - 3 = 0
(x - 3) ^ 2 = 3(x - 3)

import sympy as sym

x = sym.symbols('x')
print ("solve - 式を解く")
print (sym.solve(8 * x - 4 - 9 * x - 1))
print (sym.solve(4 * x * x - 100))
print (sym.solve(3 * x * x - 7 * x + 4))
print (sym.solve(2 * x * x + 4 * x - 48))
print (sym.solve(5 * x * x - 2 * x - 3))
print (sym.solve(5 * x * x - 3))
print (sym.solve((x - 3) * (x - 3) - 3 * (x -3)))
print (sym.solve(2 * x * x + 3 * x - 5))

問題2

xyz = -234
x + y + z = 20
5x – y + 2z = 85

import sympy as sym

x, y, z = sym.symbols('x y z')
f0 = x * y * z + 234
f1 = x + y + z - 20
f2 = 5 * x - y + 2 * z - 85
print ("solve - 式を解く")
print (sym.solve((f0, f1, f2)))

問題3

2 * x + 3 * y = 6
1 * x + 2 * y = 3

import sympy as sym

x, y = sym.symbols('x y')
f0 = 2 * x + 3 * y - 6
f1 = 1 * x + 2 * y - 3
print ("solve - 式を解く")
print (sym.solve((f0, f1)))

問題4

x^2 - 10x + 24 = 0 のとき、xを求めよ。

import sympy as sym

x = sym.symbols('x')
f = x ** 2 - 10 * x + 24
print ("expand - 展開")
# print (sym.expand(f))
print ("factor - 因数分解")
print (sym.factor(f))
print ("simplify - 簡約")
# print (sym.simplify(f))
print ("limit - 極限")
# print (sym.limit(f, x, sym.oo))
print (sym.limit(f, x, 0))
print ("diff - 微分")
# print (sym.diff(f))
print ("integrate - 積分")
# print (sym.integrate(f))
print ("solve - 式を解く")
print (sym.solve(f))

問題5

2 * x + 2 * y + 6 * z + 3 = 0
x + y - 2 * z - 7 = 0
5 * x - 9 * y + 2 * z - 15 = 0

import sympy as sym

x, y, z = sym.symbols('x y z')
fuc1 = 2 * x + 2 * y + 6 * z + 3
fuc2 = x + y - 2 * z - 7
fuc3 = 5 * x - 9 * y + 2 * z - 15
print (sym.solve([fuc1, fuc2, fuc3], [x, y, z]))

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?