## 2019年3月2日土曜日

### 数学 - Python - 大小関係を見る - 不等式 – 不等式の証明 – 分数式の不等式(正の数、平方、大小)

1. $\begin{array}{}\left({A}^{2}+{B}^{2}\right)-\left({x}^{2}+{y}^{2}\right)\\ =\frac{{\left(ax+by\right)}^{2}+{\left(bx+ay\right)}^{2}}{{\left(a+b\right)}^{2}}-\left({x}^{2}+{y}^{2}\right)\\ =\frac{{a}^{2}{x}^{2}+{b}^{2}{y}^{2}+{b}^{2}{x}^{2}+{a}^{2}{y}^{2}+4abxy}{{\left(a+b\right)}^{2}}-\left({x}^{2}+{y}^{2}\right)\\ =\frac{\left({a}^{2}+{b}^{2}\right)\left({x}^{2}+{y}^{2}\right)+4abxy}{{\left(a+b\right)}^{2}}-\left({x}^{2}+{y}^{2}\right)\\ =\frac{\left({a}^{2}+{b}^{2}\right)\left({x}^{2}+{y}^{2}\right)+4abxy-{\left(a+b\right)}^{2}\left({x}^{2}+{y}^{2}\right)}{{\left(a+b\right)}^{2}}\\ =\frac{\left({a}^{2}+{b}^{2}\right)\left({x}^{2}+{y}^{2}\right)+4abxy-\left({a}^{2}+{b}^{2}+2ab\right)\left({x}^{2}+{y}^{2}\right)}{{\left(n+b\right)}^{2}}\\ =\frac{4abxy-2ab\left({x}^{2}+{y}^{2}\right)}{{\left(a+b\right)}^{2}}\\ =\frac{2ab\left(2xy-{x}^{2}-{y}^{2}\right)}{{\left(a+b\right)}^{2}}\\ =\frac{-2ab{\left(x-y\right)}^{2}}{{\left(a+b\right)}^{2}}\\ \le 0\end{array}$

よって、

${A}^{2}+{B}^{2}\le {x}^{2}+{y}^{2}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols
from sympy.plotting import plot3d
import random

print('30.')

x, y = symbols('x, y')
a = random.randrange(1, 11)
b = random.randrange(1, 11)

A = (a * x + b * y) / (a + b)
B = (b * x + a * y) / (a + b)
f = (x ** 2 + y ** 2) - (A ** 2 + B ** 2)

print(f'a = {a}, b = {b}')

p = plot3d(f, show=False)

p.xlabel = x
p.ylabel = y
p.show()
p.save('sample30.png')


C:\Users\...> py -3 sample30.py
30.
a = 6, b = 2

C:\Users\...>