#!/usr/bin/env python3from sympy import pprint, symbols, Derivative, plot
print('1.')
x, a, n = symbols('x, a, n', real=True)
fs = [x ** 3 - 3 * x,
x ** 4 - 6 * x ** 2 + 3,
1 / (1 + 2 * a * x + x ** 2),
x ** n / (1 - x ** n)]
for i, f inenumerate(fs, 1):
print(f'({i})')
d = Derivative(f, x, 1)
for o in [d, d.doit()]:
pprint(o.factor())
print()
p = plot(*[f.subs({a: 2, n: 3}) for f in fs],
ylim=(-10, 10),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color inzip(p, colors):
o.line_color = color
p.show()
p.save('sample1.png')
0 コメント:
コメントを投稿