## 2019年10月8日火曜日

### 数学 - Python - 急速・緩慢に変化する関係 - 指数関数・対数関数 - 対数関数の性質 - いくつかの例題および問題の補充 - 2変数、和、最大値

1. $\begin{array}{l}y=\frac{20-2x}{5}\\ =4-\frac{2}{5}x\\ x>\frac{5}{2}·4=10\\ {\mathrm{log}}_{10}x+{\mathrm{log}}_{10}y\\ ={\mathrm{log}}_{10}\left(xy\right)\\ ={\mathrm{log}}_{10}\left(x\left(4-\frac{2}{5}x\right)\right)\end{array}$

よって、

$x\left(4-\frac{2}{5}x\right)=5x\left(20-2x\right)$

が最大値をとるときに、

${\mathrm{log}}_{10}x+{\mathrm{log}}_{10}y$

は最大となる。

よって、

$x=5,y=2$

のときに最大値をとるので、求める最大値は、

$\begin{array}{l}{\mathrm{log}}_{10}5+{\mathrm{log}}_{10}2\\ ={\mathrm{log}}_{10}\left(5·2\right)\\ ={\mathrm{log}}_{10}10\\ =1\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, log, plot

print('34.')

x = symbols('x')
y = -2 * x / 5 + 4
f = log(x, 10) + log(y, 10)

p = plot((f, (x, 0.1, 10)),
(f, (x, 10, 15)),
(1, (x, 0, 15)),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for s, color in zip(p, colors):
s.line_color = color

p.show()
p.save(f'sample34.png')


$./sample34.py 34. /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sympy/plotting/experimental_lambdify.py:233: UserWarning: The evaluation of the expression is problematic. We are trying a failback method that may still work. Please report this as a bug. warnings.warn('The evaluation of the expression is'$