2020年5月27日水曜日

学習環境

代数への出発 (新装版 数学入門シリーズ) (松坂 和夫(著)、岩波書店)の第6章(1次方程式、2次方程式)、3(1次関数とそのグラフ)問7の解答を求めてみる。



    1. y=x-1={-x+1x1x-1x1

      グラフ。


    2. y=x-1+x+1={-x+1-x-1x-1-x+1+x+1-1x1x-1+x+11x={-2xx-12-1x12x1x

      グラフ。


    3. y=x+x2={-x+x2x0x+x2x0={0x0xx0

      グラフ。


    4. y=x-1+2x+4-2x-4={-x+1-2x-4+2x-4x-2-x+1+2x+4+2x-4-2x1x-1+2x+4+2x-41x2x-1+2x+4-2x+4x2={-x-7x-23x+1-2x15x-11x2x+7x2

      グラフ。

コード

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

print('7.')
x = symbols('x')


p = plot(abs(x - 1),
         abs(x - 1) + abs(x + 1),
         (abs(x) + x) / 2,
         abs(x - 1) + abs(2 * x + 4) - abs(2 * x - 4),
         (x, -10, 10),
         ylim=(-10, 10),
         legend=True,
         show=False)

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

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

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

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

% ./sample7.py
7.
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1065: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  self.ax[i].spines['left'].set_smart_bounds(True)
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1066: MatplotlibDeprecationWarning: 
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
  self.ax[i].spines['bottom'].set_smart_bounds(False)
%

0 コメント:

コメントを投稿