<jupyter_start><jupyter_text>Домашнее задание "Математический анализ. Производная".  Уровень 0: Посчитайте значение первой и второй производной функции:$f(x) = x^5 + 4sin(2x) + cos(3x+3)$ В точке x = 1. Analytical solution:$f'(x) = 5x^4 + 8cos(2x) - 3sin(3x+3)$$f''(x) = 20x^3 - 16sin(2x) - 9cos(3x+3)$<jupyter_code>import math
from scipy.misc import derivative

def f(x):
    y = x**5+4*math.sin(2*x)+math.cos(3*x+3)
    return y

def f1(x):
    y = 5*x**4+8*math.cos(2*x)-3*math.sin(3*x+3)
    return y

def f2(x):
    y = 20*x**3-16*math.sin(2*x)-9*math.cos(3*x+3)
    return y

dx1 = derivative(f, 1.0, dx=1e-6)
print("dx1: {}; f1(1):{}".format(dx1, f1(1.0)))
dx2 = derivative(f, 1.0, dx=1e-6, n=2)
print("dx2: {}; f2(1):{}".format(dx2, f2(1.0)))<jupyter_output>dx1: 2.509071801881646; f1(1):2.5090718022196383
dx2: -3.19033688356285; f2(1):-3.1902914090642014<jupyter_text>Уровень 1: Постройте график первой и второй производной функции:$f(x) = sin^5(2x+1)$На отрезке [-5; 5].<jupyter_code>from sympy import *
from numpy import linspace
import matplotlib.pyplot as pl

x = symbols('x')
y = sin(2 * x + 1) ** 5
y1 = diff(y, x)
print(format(y1))

lam_y1 = lambdify(x, y1, modules=['numpy'])

x_vals = linspace(-5, 5, 1000)
y_vals = lam_y1(x_vals)

pl.plot(x_vals, y_vals)
pl.show()
y2 = diff(y1, x)
print(format(y2))

lam_y2 = lambdify(x, y2, modules=['numpy'])

x_vals = linspace(-5, 5, 1000)
y_vals = lam_y2(x_vals)

pl.plot(x_vals, y_vals)
pl.show()<jupyter_output>-20*sin(2*x + 1)**5 + 80*sin(2*x + 1)**3*cos(2*x + 1)**2
{'fraction_non_alphanumeric': 0.2089063523248199, 'fraction_numerical': 0.12246234446627374, 'mean_word_length': 5.087649402390438, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '406311', 'license': 'MIT', 'n_tokens_mistral': 858, 'n_tokens_neox': 801, 'n_words': 139, 'path': 'HW_4.ipynb', 'repo_name': 'seoSergio/mds-16', 'size': '1527'}