53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
def trig_part(x):
|
|
s = np.sin(x)
|
|
c = np.cos(x)
|
|
t = np.tan(x)
|
|
cot = 1.0 / t
|
|
sec = 1.0 / c
|
|
csc = 1.0 / s
|
|
inner = (t / csc + s) / (s ** 3)
|
|
num = inner * cot + t + (cot + c) / c
|
|
return (num / s) * (csc - sec * t)
|
|
|
|
def log_part(x):
|
|
l2 = np.log(x) / np.log(2)
|
|
l3 = np.log(x) / np.log(3)
|
|
l5 = np.log(x) / np.log(5)
|
|
l10 = np.log10(x)
|
|
num = ((l5 / l2) - l5) / l10
|
|
den = l3 ** 3 - l5 ** 3
|
|
return (num / den) * (l5 / l10)
|
|
|
|
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5))
|
|
|
|
x_neg = np.linspace(-4 * np.pi, -0.01, 5000)
|
|
y_neg = trig_part(x_neg)
|
|
y_neg = np.where(np.abs(y_neg) > 50, np.nan, y_neg)
|
|
|
|
ax1.plot(x_neg, y_neg, 'b-', linewidth=0.8)
|
|
ax1.set_title('x ≤ 0 (тригонометрическая часть)')
|
|
ax1.set_xlabel('x')
|
|
ax1.set_ylabel('f(x)')
|
|
ax1.set_ylim(-50, 50)
|
|
ax1.grid(True, alpha=0.3)
|
|
ax1.axhline(y=0, color='k', linewidth=0.5)
|
|
|
|
x_pos = np.linspace(0.01, 10, 5000)
|
|
y_pos = log_part(x_pos)
|
|
y_pos = np.where(np.abs(y_pos) > 20, np.nan, y_pos)
|
|
|
|
ax2.plot(x_pos, y_pos, 'r-', linewidth=0.8)
|
|
ax2.set_title('x > 0 (логарифмическая часть)')
|
|
ax2.set_xlabel('x')
|
|
ax2.set_ylabel('f(x)')
|
|
ax2.set_ylim(-20, 20)
|
|
ax2.grid(True, alpha=0.3)
|
|
ax2.axhline(y=0, color='k', linewidth=0.5)
|
|
|
|
plt.suptitle('Система функций (вариант 93822)', fontsize=14, fontweight='bold')
|
|
plt.tight_layout()
|
|
plt.savefig('images.png', dpi=150, bbox_inches='tight')
|
|
plt.show() |