2019年5月17日金曜日

学習環境

数学読本〈2〉簡単な関数/平面図形と式/指数関数・対数関数/三角関数 (松坂 和夫(著)、岩波書店)の第5章(関連しながら変化する世界 - 簡単な関数)、5.3(分数関数・無理関数)、簡単な分数方程式・分数不等式の問33の解答を求めてみる。



    1. x+32=1x2x2+3x-2=0(2x-1)(x+2)=0x=-2,12

      よって、求める不等式の解は、

      -2<x<0,12<x

    2. 5x+2=x-2x2-4=5x2=9x=±3x-3,-2<x3

    3. xx-1=2x-2x=2(x2-2x+1)2x2-5x+2=0(2x-1)(x-2)=0x=12,2xx-1=x-1+1x-1=1x-1+112x<1,2x

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, Rational, Poly
from sympy.solvers.inequalities import reduce_rational_inequalities
print('33.')

x = symbols('x', real=True)
fs = [x + Rational(3, 2), 5 / (x + 2), x / (x - 1)]
gs = [1 / x, x - 2, 2 * x - 2]
inequalities = ['>', '>=', '<=']

for i, (a, b, c) in enumerate(zip(fs, gs, inequalities), 1):
    print(f'({i})')
    pprint(reduce_rational_inequalities([[(a - b, c)]], x))
    print()

p = plot(*fs,
         *gs,
         (x, -5, 5),
         ylim=(-5, 5),
         legend=True,
         show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'gray', 'skyblue', 'yellow']

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

p.show()
p.save('sample33.png')

入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))

C:\Users\...>py sample33.py
33.
(1)
(-2 < x ∧ x < 0) ∨ (1/2 < x ∧ x < ∞)

(2)
(x ≤ -3 ∧ -∞ < x) ∨ (x ≤ 3 ∧ -2 < x)

(3)
(1/2 ≤ x ∧ x < 1) ∨ (2 ≤ x ∧ x < ∞)


C:\Users\...>

0 コメント:

コメントを投稿