Compare commits
9 Commits
be0a196457
...
5c3084deeb
Author | SHA1 | Date | |
---|---|---|---|
|
5c3084deeb | ||
|
29ef7018a5 | ||
|
63d5668224 | ||
|
cba0a8514d | ||
|
c1ee0fe5ce | ||
|
a25e301f1e | ||
|
a2d84c7583 | ||
|
4ad96347fb | ||
|
b39269901c |
@ -13,6 +13,12 @@
|
||||
"pdflatex"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "latexmk (xelatex)",
|
||||
"tools": [
|
||||
"xelatexmk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "latexmk",
|
||||
"tools": [
|
||||
@ -109,5 +115,6 @@
|
||||
}
|
||||
],
|
||||
"latex-workshop.latex.rootFile.indicator": "\\begin{document}",
|
||||
"latex-workshop.latex.recipe.default": "lastUsed",
|
||||
}
|
||||
}
|
||||
|
51
appendix.tex
@ -14,6 +14,51 @@
|
||||
\addcontentsline{toc}{chapter}{Приложения}
|
||||
\appendix
|
||||
|
||||
% \section{Скрипты установки БД для компонента <<Хранение~данных>>}
|
||||
% \label{script:storage}
|
||||
% \inputcode{../software/architecture/first-level/component-storage/CSt.db-script.sql}{frame=none,language=sql}
|
||||
|
||||
\section{Результаты вывода программы}
|
||||
\label{output_program}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/Thomas}
|
||||
\caption{Вывод программы для решения СЛУ методом прогонки}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/Inverted}
|
||||
\caption{Вывод программы для решения СЛУ методом обратной матрицы}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/lagrange}
|
||||
\caption{График интерполяции функции методом Лагранжа}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/newton}
|
||||
\caption{График интерполяции функции методом Ньютона}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/CubicSpline}
|
||||
\caption{График сплайн-интерполяции функции с помощью \textbf{CubicSpline}}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/PchipInterpolator}
|
||||
\caption{График сплайн-интерполяции функции с помощью \textbf{PchipInterpolator}}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/CubicHermiteSpline}
|
||||
\caption{График сплайн-интерполяции функции с помощью \textbf{CubicHermiteSpline}}
|
||||
\end{figure}
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/Akima1DInterpolator}
|
||||
\caption{График сплайн-интерполяции функции с помощью \textbf{Akima1DInterpolator}}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\section{Листинг программы}
|
||||
\label{program_code}
|
||||
\inputcode{code/main.py}{frame=none,language=python}
|
||||
|
BIN
assets/Akima1DInterpolator.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
assets/CubicHermiteSpline.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
assets/CubicSpline.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
assets/Gauss.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
assets/Inverted.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
assets/PchipInterpolator.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
assets/Thomas.png
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
assets/bisect.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
assets/curve_fit.png
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
assets/lagrange.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
assets/least_squares.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
assets/newton.png
Normal file
After Width: | Height: | Size: 30 KiB |
236
code/main.py
@ -16,16 +16,16 @@ def plt_append(sp, x: list[float], y: list[float], label: str, format: str):
|
||||
sp.plot(x, y, format, label=label)
|
||||
|
||||
|
||||
def generate_array(min, max, density=10):
|
||||
point_count = int(m.fabs(max-min)*density)
|
||||
x = np.linspace(min, max, point_count)
|
||||
return list(x.tolist())
|
||||
|
||||
|
||||
class NonLinear:
|
||||
bisect_exp = "x**2 * np.sin(x)"
|
||||
newton_exp = "np.sin(x) * np.sqrt(np.abs(x))"
|
||||
|
||||
@staticmethod
|
||||
def generate_array(min, max):
|
||||
point_count = int(m.fabs(max-min))*10
|
||||
x = np.linspace(min, max, point_count)
|
||||
return list(x.tolist())
|
||||
|
||||
@staticmethod
|
||||
def slice_array(range: list[float], val_min, val_max):
|
||||
def index_search(range: list[float], val):
|
||||
@ -54,7 +54,7 @@ class NonLinear:
|
||||
def plot_bisect():
|
||||
bounds = 0, 6
|
||||
split_val = 1
|
||||
x1 = NonLinear.generate_array(bounds[0], bounds[1])
|
||||
x1 = generate_array(bounds[0], bounds[1])
|
||||
x2 = NonLinear.slice_array(x1, split_val, None)
|
||||
|
||||
sp = create_subplot()
|
||||
@ -65,9 +65,9 @@ class NonLinear:
|
||||
plt_append(
|
||||
sp, x1, sol1[0], f"Исходные данные (y={NonLinear.bisect_exp})", "-b")
|
||||
plt_append(
|
||||
sp, *(sol1[1]), f"bisect at [{bounds[0]},{bounds[1]}]", "or")
|
||||
sp, *(sol1[1]), f"bisect на [{bounds[0]},{bounds[1]}]", "or")
|
||||
plt_append(
|
||||
sp, *(sol2[1]), f"bisect at [{split_val},{bounds[1]}]", "og")
|
||||
sp, *(sol2[1]), f"bisect на [{split_val},{bounds[1]}]", "og")
|
||||
|
||||
sp.set_title("scipy.optimize.bisect")
|
||||
sp.legend(loc='lower left')
|
||||
@ -84,7 +84,7 @@ class NonLinear:
|
||||
def plot_newton():
|
||||
bounds = -2, 7
|
||||
split_l, split_r = 2, 5
|
||||
x1 = NonLinear.generate_array(bounds[0], bounds[1])
|
||||
x1 = generate_array(bounds[0], bounds[1])
|
||||
x2 = NonLinear.slice_array(x1, split_l, split_r)
|
||||
x0_1, x0_2 = 1/100, 4
|
||||
sp = create_subplot()
|
||||
@ -95,9 +95,9 @@ class NonLinear:
|
||||
plt_append(
|
||||
sp, x1, sol1[0], f"Исходные данные (y={NonLinear.newton_exp})", "-b")
|
||||
plt_append(
|
||||
sp, *(sol1[1]), f"newton at [{bounds[0]},{bounds[1]}]", "or")
|
||||
sp, *(sol1[1]), f"newton на отрезке [{bounds[0]},{bounds[1]}]", "or")
|
||||
plt_append(
|
||||
sp, *(sol2[1]), f"newton at [{split_l},{bounds[1]}]", "og")
|
||||
sp, *(sol2[1]), f"newton на отрезке [{split_l},{bounds[1]}]", "og")
|
||||
|
||||
sp.set_title("scipy.optimize.newton")
|
||||
sp.legend(loc='lower left')
|
||||
@ -137,7 +137,8 @@ class SLE:
|
||||
new_data = []
|
||||
new_len = len(data[0][0])
|
||||
zipped = list(zip(*tuple(data[0])))
|
||||
zipped[len(zipped)-1] = (zipped[len(zipped)-1][0],zipped[len(zipped)-2][1])
|
||||
zipped[len(zipped)-1] = (zipped[len(zipped)-1]
|
||||
[0], zipped[len(zipped)-2][1])
|
||||
complement_to = new_len - len(zipped[0])
|
||||
for i, val in enumerate(zipped):
|
||||
zero_r = complement_to - i
|
||||
@ -159,7 +160,7 @@ class SLE:
|
||||
if coef != 0:
|
||||
print(f"({coef}{SLE.var_str(i_coef)}) + ", end='')
|
||||
else:
|
||||
print(f" {coef} + ",end='')
|
||||
print(f" {coef} + ", end='')
|
||||
print(f"({val[-1]}{SLE.var_str(len(val)-1)})", end='')
|
||||
print(f" = {data[1][i]}")
|
||||
|
||||
@ -213,12 +214,215 @@ class SLE:
|
||||
if method in ["banded", "all"]:
|
||||
SLE.print_tridiagonal()
|
||||
|
||||
|
||||
class Approx:
|
||||
function = "np.sin(x) * np.sqrt(np.abs(x))"
|
||||
function_exp = "np.sin(x) * np.sqrt(np.abs(x))"
|
||||
least_sq_exp = "np.sin(x) * np.abs(x)"
|
||||
|
||||
@staticmethod
|
||||
def get_function_exp_der(*args):
|
||||
function_der_exp = "(x * np.sin(x) + 2 * x**2 * np.cos(x)) / (2 * np.sqrt(np.abs(x)) ** 3)"
|
||||
result = ()
|
||||
for i in args:
|
||||
array = []
|
||||
for x in i:
|
||||
array.append(eval(function_der_exp))
|
||||
|
||||
result = result + (array,)
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def generate_y(x_array, function):
|
||||
result = []
|
||||
for x in x_array:
|
||||
result.append(eval(function))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def lagrange(x, y):
|
||||
return sitp.lagrange(x, y)
|
||||
|
||||
@staticmethod
|
||||
def get_approx_data(function=function_exp, bounds=[-6, 6]):
|
||||
x1 = generate_array(bounds[0], bounds[1], 1/2)
|
||||
x2 = generate_array(bounds[0], bounds[1], 1)
|
||||
y1 = Approx.generate_y(x1, function)
|
||||
y2 = Approx.generate_y(x2, function)
|
||||
x_real = generate_array(bounds[0], bounds[1])
|
||||
y_real = Approx.generate_y(x_real, function)
|
||||
return x1, x2, y1, y2, x_real, y_real
|
||||
|
||||
@staticmethod
|
||||
def plot_lagrange():
|
||||
x1, x2, y1, y2, x_real, y_real = Approx.get_approx_data()
|
||||
|
||||
sp = create_subplot()
|
||||
sol1 = np.polynomial.polynomial.Polynomial(
|
||||
Approx.lagrange(x1, y1).coef[::-1])
|
||||
sol2 = np.polynomial.polynomial.Polynomial(
|
||||
Approx.lagrange(x2, y2).coef[::-1])
|
||||
|
||||
plt_append(
|
||||
sp, x_real, y_real, f"Исходные данные (y={Approx.function_exp})", "--b")
|
||||
plt_append(
|
||||
sp, x_real, sol1(np.array(x_real)), f"f1 = lagrange, кол-во точек = {len(x1)}", "-m")
|
||||
plt_append(
|
||||
sp, x_real, sol2(np.array(x_real)), f"f2 = lagrange, кол-во точек = {len(x2)}", "-r")
|
||||
plt_append(
|
||||
sp, x1, y1, f"Исходные точки для f1", ".m")
|
||||
plt_append(
|
||||
sp, x2, y2, f"Исходные точки для f2", ".r")
|
||||
|
||||
sp.set_title("scipy.interpolate.lagrange")
|
||||
sp.legend(loc='lower left')
|
||||
|
||||
@staticmethod
|
||||
def plot_spline():
|
||||
x1, x2, y1, y2, x_real, y_real = Approx.get_approx_data()
|
||||
d1, d2 = Approx.get_function_exp_der(x1, x2)
|
||||
|
||||
for interpolator in [sitp.CubicSpline,
|
||||
sitp.PchipInterpolator,
|
||||
sitp.CubicHermiteSpline,
|
||||
sitp.Akima1DInterpolator]:
|
||||
sp = create_subplot()
|
||||
|
||||
if interpolator.__name__ != "CubicHermiteSpline":
|
||||
args1 = x1, y1
|
||||
args2 = x2, y2
|
||||
else:
|
||||
args1 = x1, y1, d1
|
||||
args2 = x2, y2, d2
|
||||
|
||||
sol1 = interpolator(*args1)
|
||||
sol2 = interpolator(*args2)
|
||||
plt_append(
|
||||
sp, x_real, y_real, f"Исходные данные (y={Approx.function_exp})", "--b")
|
||||
plt_append(
|
||||
sp, x_real, sol1(np.array(x_real)), f"f1 = {interpolator.__name__}, кол-во точек = {len(x1)}", "-m")
|
||||
plt_append(
|
||||
sp, x_real, sol2(np.array(x_real)), f"f2 = {interpolator.__name__}, кол-во точек = {len(x2)}", "-r")
|
||||
plt_append(
|
||||
sp, x1, y1, f"Исходные точки для f1", ".m")
|
||||
plt_append(
|
||||
sp, x2, y2, f"Исходные точки для f2", ".r")
|
||||
|
||||
sp.set_title(f"scipy.interpolate.{interpolator.__name__}")
|
||||
sp.legend(loc='lower left')
|
||||
|
||||
@staticmethod
|
||||
def linear(x, a, b):
|
||||
return a*x + b
|
||||
|
||||
@staticmethod
|
||||
def quadratic(x, a, b, c):
|
||||
return a * (x**2) + (b*x) + c
|
||||
|
||||
@staticmethod
|
||||
def fract(x, a, b, c):
|
||||
return x / (a * x + b) - c
|
||||
|
||||
@staticmethod
|
||||
def noise_y(y, rng):
|
||||
diff = max(y) - min(y)
|
||||
noise_coeff = diff*(10/100)
|
||||
return y + (noise_coeff * rng.normal(size=len(y)))
|
||||
|
||||
@staticmethod
|
||||
def plot_least_squares_curvefit():
|
||||
rng = np.random.default_rng()
|
||||
bounds = [3, 6]
|
||||
x1, x2, y1, y2, x_real, y_real = Approx.get_approx_data(
|
||||
Approx.least_sq_exp, bounds)
|
||||
x_real = np.array(x_real)
|
||||
|
||||
y_real = Approx.noise_y(y_real, rng)
|
||||
base_functions = [Approx.linear,
|
||||
Approx.quadratic, (Approx.fract, "x/(ax+b)")]
|
||||
|
||||
sp = create_subplot()
|
||||
plt_append(
|
||||
sp, x_real, y_real, f"y={Approx.least_sq_exp} на [{bounds[0]};{bounds[1]}], с шумом", ".b")
|
||||
for bf in base_functions:
|
||||
if isinstance(bf, tuple):
|
||||
bf, desc = bf[0], bf[1]
|
||||
else:
|
||||
bf, desc = bf, None
|
||||
optimal_params, _ = sopt.curve_fit(bf, x_real, y_real)
|
||||
desc_str = f" ({desc}) " if desc is not None else ""
|
||||
plt_append(
|
||||
sp, x_real, bf(np.array(x_real), *optimal_params),
|
||||
f"МНК, вид функции - {bf.__name__}{desc_str}", "-")
|
||||
sp.set_title(f"scipy.optimize.curve_fit")
|
||||
sp.legend(loc='lower left')
|
||||
|
||||
@staticmethod
|
||||
def plot_least_squares():
|
||||
rng = np.random.default_rng()
|
||||
|
||||
def exponential(x, a, b, c):
|
||||
return np.sin(x) * np.sqrt(np.abs(x))
|
||||
exponential.str = "np.sin(x) * np.sqrt(np.abs(x))"
|
||||
|
||||
def gen_y(x, a, b, c, noise=0., n_outliers=0):
|
||||
y = exponential(x, a, b, c)
|
||||
error = noise * rng.standard_normal(x.size)
|
||||
outliers = rng.integers(0, x.size, n_outliers)
|
||||
error[outliers] *= 10
|
||||
return y + error
|
||||
|
||||
def loss(params, x, y):
|
||||
return (exponential(x, params[0], params[1], params[2])) - y
|
||||
params0 = np.array([0.1, 1, 0])
|
||||
bounds = [-5, 3]
|
||||
params_real = (3, 1, 5)
|
||||
x_approx = np.array(generate_array(bounds[0], bounds[1], 4))
|
||||
y_approx = np.array(gen_y(x_approx, *params_real,
|
||||
noise=0.3, n_outliers=4))
|
||||
|
||||
params_lsq = sopt.least_squares(
|
||||
loss, params0, loss='linear', args=(x_approx, y_approx)).x
|
||||
params_soft_l1 = sopt.least_squares(
|
||||
loss, params0, loss='soft_l1', args=(x_approx, y_approx),f_scale=0.1).x
|
||||
params_cauchy = sopt.least_squares(
|
||||
loss, params0, loss='cauchy', args=(x_approx, y_approx), f_scale=2).x
|
||||
|
||||
x_real = np.array(generate_array(bounds[0], bounds[1]))
|
||||
y_real = np.array(gen_y(x_real, *params_real, 0, 0))
|
||||
|
||||
sp = create_subplot()
|
||||
sp.plot(x_real, y_real, "-b",
|
||||
label=f"y={exponential.str} на [{bounds[0]};{bounds[1]}]")
|
||||
sp.plot(x_approx, y_approx, ".r", label=f"Табличные значения с шумом")
|
||||
sp.plot(x_real, gen_y(x_real, *params_lsq), color="green",
|
||||
label=f"loss=\"linear\"", linestyle=(0, (5, 10)))
|
||||
sp.plot(x_real, gen_y(x_real, *params_soft_l1), color="magenta",
|
||||
label=f"loss=\"soft_l1\"", linestyle=(5, (5, 10)))
|
||||
sp.plot(x_real, gen_y(x_real, *params_cauchy), color="black",
|
||||
label=f"loss=\"cauchy\"", linestyle=(7, (5, 10)))
|
||||
|
||||
sp.set_title(f"scipy.optimize.least_squares")
|
||||
sp.legend(loc='lower left')
|
||||
|
||||
@staticmethod
|
||||
def plot(method: str = "all"):
|
||||
if method in ["lagrange", "all"]:
|
||||
Approx.plot_lagrange()
|
||||
if method in ["spline", "all"]:
|
||||
Approx.plot_spline()
|
||||
if method in ["least_squares_curvefit", "all"]:
|
||||
Approx.plot_least_squares_curvefit()
|
||||
if method in ["least_squares", "all"]:
|
||||
Approx.plot_least_squares()
|
||||
plt.ylabel("y")
|
||||
plt.xlabel("x")
|
||||
plt.show()
|
||||
|
||||
|
||||
def main():
|
||||
# NonLinear.plot()
|
||||
NonLinear.plot()
|
||||
SLE.print()
|
||||
Approx.plot()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
15
conclusion.tex
Normal file
@ -0,0 +1,15 @@
|
||||
\chapter*{Заключение}
|
||||
|
||||
В ходе выполнения работы были выполнены поставленные задачи, цель
|
||||
достигнута. В ходе исследования возможностей библиотек выяснилось,
|
||||
что они не содержат реализаций численных методов для
|
||||
решения систем нелинейных уравнений.
|
||||
|
||||
В целом, в ходе работы с библиотеками стоит отметить положительные
|
||||
стороны: гибкость интерфейсов, высокое качество решений, большое
|
||||
количество доступной информации о результатах работы алгоритма.
|
||||
|
||||
Из недостатков интерфейса библиотек можно отметить его неоднородность ---
|
||||
некоторые численные методы реализованы с помощью классов, другие
|
||||
с помощью функций, что может незначительно увеличить время на
|
||||
освоение интерфейса библиотек и ее возможностей пользователями.
|
68
config.tex
@ -5,6 +5,7 @@
|
||||
\usepackage{threeparttable}
|
||||
\usepackage[labelsep=endash,tableposition=top,labelfont=md,textfont=md]{caption}
|
||||
\usepackage{indentfirst}
|
||||
\usepackage{float}
|
||||
\usepackage{rotating}
|
||||
\usepackage{setspace}
|
||||
\usepackage{array}
|
||||
@ -111,6 +112,73 @@
|
||||
tabsize=3,
|
||||
escapechar={|},
|
||||
emptylines=0,
|
||||
extendedchars=true,
|
||||
literate={а}{{\cyra}}1
|
||||
{б}{{\cyrb}}1
|
||||
{в}{{\cyrv}}1
|
||||
{г}{{\cyrg}}1
|
||||
{д}{{\cyrd}}1
|
||||
{е}{{\cyre}}1
|
||||
{ё}{\"{\cyre}}1
|
||||
{ж}{{\cyrzh}}1
|
||||
{з}{{\cyrz}}1
|
||||
{и}{{\cyri}}1
|
||||
{й}{{\cyrishrt}}1
|
||||
{к}{{\cyrk}}1
|
||||
{л}{{\cyrl}}1
|
||||
{м}{{\cyrm}}1
|
||||
{н}{{\cyrn}}1
|
||||
{о}{{\cyro}}1
|
||||
{п}{{\cyrp}}1
|
||||
{р}{{\cyrr}}1
|
||||
{с}{{\cyrs}}1
|
||||
{т}{{\cyrt}}1
|
||||
{у}{{\cyru}}1
|
||||
{ф}{{\cyrf}}1
|
||||
{х}{{\cyrh}}1
|
||||
{ц}{{\cyrc}}1
|
||||
{ч}{{\cyrch}}1
|
||||
{ш}{{\cyrsh}}1
|
||||
{щ}{{\cyrshch}}1
|
||||
{ъ}{{\cyrhrdsn}}1
|
||||
{ы}{{\cyrery}}1
|
||||
{ь}{{\cyrsftsn}}1
|
||||
{э}{{\cyrerev}}1
|
||||
{ю}{{\cyryu}}1
|
||||
{я}{{\cyrya}}1
|
||||
{А}{{\CYRA}}1
|
||||
{Б}{{\CYRB}}1
|
||||
{В}{{\CYRV}}1
|
||||
{Г}{{\CYRG}}1
|
||||
{Д}{{\CYR96}}1
|
||||
{Е}{{\CYRE}}1
|
||||
{Ё}{{\"{\CYRE}}}1
|
||||
{Ж}{{\CYRZH}}1
|
||||
{З}{{\CYRZ}}1
|
||||
{И}{{\CYRI}}1
|
||||
{Й}{{\CYRISHRT}}1
|
||||
{К}{{\CYRK}}1
|
||||
{Л}{{\CYRL}}1
|
||||
{М}{{\CYRM}}1
|
||||
{Н}{{\CYRN}}1
|
||||
{О}{{\CYRO}}1
|
||||
{П}{{\CYRP}}1
|
||||
{Р}{{\CYRR}}1
|
||||
{С}{{\CYRS}}1
|
||||
{Т}{{\CYRT}}1
|
||||
{У}{{\CYRU}}1
|
||||
{Ф}{{\CYRF}}1
|
||||
{Х}{{\CYRH}}1
|
||||
{Ц}{{\CYRC}}1
|
||||
{Ч}{{\CYRCH}}1
|
||||
{Ш}{{\CYRSH}}1
|
||||
{Щ}{{\CYRSHCH}}1
|
||||
{Ъ}{{\CYRHRDSN}}1
|
||||
{Ы}{{\CYRERY}}1
|
||||
{Ь}{{\CYRSFTSN}}1
|
||||
{Э}{{\CYREREV}}1
|
||||
{Ю}{{\CYRYU}}1
|
||||
{Я}{{\CYRYA}}1
|
||||
}
|
||||
\newcommand\inputcode[3][]{
|
||||
{\bfseries #1\filename{#2}}:
|
||||
|
64
experimental_research.tex
Normal file
@ -0,0 +1,64 @@
|
||||
\chapter{Экспериментальное исследование возможностей библиотек}
|
||||
Для исследования возможностей библиотек была разработана программа
|
||||
на языке Python. Она позволяет изучить работу наиболее популярных
|
||||
численных методов: методов решения нелинейных уравнений и
|
||||
СЛУ, а также аппроксимации функций.
|
||||
|
||||
Ее структура состоит из классов \textbf{NonLinear}, \textbf{SLE},
|
||||
\textbf{Approx}. Они состоят только из статических методов,
|
||||
пользовательских родительских классов не имеют.
|
||||
|
||||
При запуске программа сначала выводит графики решений нелинейных
|
||||
уравнений в отдельных окнах (рисунок \ref{bisect}, рисунок\ref{newton}),
|
||||
входные и выходные данные для методов решения СЛУ в терминале, и
|
||||
затем результаты аппроксимации, так же в виде графиков в отдельных
|
||||
окнах.
|
||||
|
||||
Результат работы метода Гаусса (вывод терминала) приведен на
|
||||
рисунке \ref{gauss}.
|
||||
|
||||
Вывод графиков осуществляется с помощью библиотеки \textbf{matplotlib},
|
||||
через функции \textbf{matplotlib.pyplot.plot} и \textbf{matplotlib.pyplot.subplots} \cite{links:matplotlib}.
|
||||
|
||||
Все графики имеют заголовок, в котором написано название функции,
|
||||
легенду в нижнем левом углу, в которой описаны данные графика.
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/bisect.png}
|
||||
\caption{Результат исследования функции bisect}
|
||||
\label{bisect}
|
||||
\end{figure}
|
||||
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/newton.png}
|
||||
\caption{Результат исследования функции newton}
|
||||
\label{newton}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\begin{figure}[ht]
|
||||
\centering
|
||||
\includegraphics[width=0.6\textwidth]{assets/Gauss.png}
|
||||
\caption{Результат решения СЛУ методом Гаусса}
|
||||
\label{gauss}
|
||||
\end{figure}
|
||||
|
||||
Для получения результатов исследования отдельных классов численных
|
||||
методов есть следующие методы:
|
||||
\begin{enumerate}
|
||||
\item \textbf{NonLinear.plot} для вывода графиков результатов
|
||||
решения нелинейных уравнений, \textbf{Approx.plot} --- для вывода
|
||||
графиков решения задачи аппроксимации.
|
||||
|
||||
\item \textbf{SLE.print} --- для вывода результатов решения
|
||||
СЛУ в терминал
|
||||
\end{enumerate}
|
||||
|
||||
Данные методы самостоятельно вызываются при запуске программы
|
||||
пользователем.
|
||||
|
||||
Вывод терминала а также графики для остальных методов приведены
|
||||
в приложении \ref{output_program}.
|
||||
|
||||
Код программы приведен в приложении \ref{program_code}.
|
73
main.tex
@ -556,41 +556,57 @@ LU-разложение \cite[с. 259]{book:levitin}. Для получения
|
||||
Обе функции принимают матрицу \(ab\) либо в верхней (\textbf{solve\_banded}), либо в нижней форме (\textbf{solveh\_banded} при
|
||||
включенной опции \(lower\)). Например, для матрицы
|
||||
|
||||
\begin{tabular}[htpb]{ccccc}
|
||||
5 & 2 & -1 & 0 & 0 \\
|
||||
1 & 4 & 2 & -1 & 0 \\
|
||||
0 & 1 & 3 & 2 & -1 \\
|
||||
0 & 0 & 1 & 2 & 2 \\
|
||||
0 & 0 & 0 & 1 & 1 \\
|
||||
\end{tabular}\\
|
||||
\begin{equation*}
|
||||
\left(
|
||||
\begin{aligned}
|
||||
5 && 2 && -1 && 0 && 0 \\
|
||||
1 && 4 && 2 && -1 && 0 \\
|
||||
0 && 1 && 3 && 2 && -1 \\
|
||||
0 && 0 && 1 && 2 && 2 \\
|
||||
0 && 0 && 0 && 1 && 1
|
||||
\end{aligned}
|
||||
\right)
|
||||
\end{equation*}
|
||||
верхняя форма будет следующей:
|
||||
|
||||
\begin{tabular}[htpb]{ccccc}
|
||||
0 & 0 & -1 & -1 & -1 \\
|
||||
0 & 2 & 2 & 2 & 2 \\
|
||||
5 & 4 & 3 & 2 & 1 \\
|
||||
1 & 1 & 1 & 1 & 0 \\
|
||||
\end{tabular}
|
||||
\begin{equation*}
|
||||
\left(
|
||||
\begin{aligned}
|
||||
0 && 0 && -1 && -1 && -1 \\
|
||||
0 && 2 && 2 && 2 && 2 \\
|
||||
5 && 4 && 3 && 2 && 1 \\
|
||||
1 && 1 && 1 && 1 && 0
|
||||
\end{aligned}
|
||||
\right)
|
||||
\end{equation*}
|
||||
|
||||
Так как данная матрица не эрмитова, и, следовательно, не положительно
|
||||
определенна, нижняя форма для нее не существует. Если взять эрмитову
|
||||
положительно определенную матрицу
|
||||
|
||||
\begin{tabular}[htpb]{cccccc}
|
||||
4 & 2 & -1 & 0 & 0 & 0 \\
|
||||
2 & 5 & 2 & -1 & 0 & 0 \\
|
||||
-1 & 2 & 6 & 2 & -1 & 0 \\
|
||||
0 & -1 & 2 & 7 & 2 & -1 \\
|
||||
0 & 0 & -1 & 2 & 8 & 2 \\
|
||||
0 & 0 & 0 & -1 & 2 & 9 \\
|
||||
\end{tabular}\\
|
||||
\begin{equation*}
|
||||
\left(
|
||||
\begin{aligned}
|
||||
4 && 2 && -1 && 0 && 0 && 0 \\
|
||||
2 && 5 && 2 && -1 && 0 && 0 \\
|
||||
-1 && 2 && 6 && 2 && -1 && 0 \\
|
||||
0 && -1 && 2 && 7 && 2 && -1 \\
|
||||
0 && 0 && -1 && 2 && 8 && 2 \\
|
||||
0 && 0 && 0 && -1 && 2 && 9
|
||||
\end{aligned}
|
||||
\right)
|
||||
\end{equation*}
|
||||
то ее нижняя форма будет следующая:
|
||||
|
||||
\begin{tabular}[htpb]{cccccc}
|
||||
4 & 5 & 6 & 7 & 8 & 9 \\
|
||||
2 & 2 & 2 & 2 & 2 & 0 \\
|
||||
-1 & -1 & -1 & -1 & 0 & 0 \\
|
||||
\end{tabular}
|
||||
\begin{equation*}
|
||||
\left(
|
||||
\begin{aligned}
|
||||
4 && 5 && 6 && 7 && 8 && 9 \\
|
||||
2 && 2 && 2 && 2 && 2 && 0 \\
|
||||
-1 && -1 && -1 && -1 && 0 && 0
|
||||
\end{aligned}
|
||||
\right)
|
||||
\end{equation*}
|
||||
|
||||
\subsection{Метод простой итерации (метод Якоби)}
|
||||
\subsubsection{Описание метода}
|
||||
@ -1904,9 +1920,8 @@ f\(x\), если \(f^{(4)}(x) = 0, x \in [a;b] \), в соответствии
|
||||
считается плотной.
|
||||
\end{itemize}
|
||||
\end{enumerate}
|
||||
\chapter{Экспериментальное исследование возможностей библиотек}
|
||||
|
||||
\chapter*{Заключение}
|
||||
\input{experimental_research}
|
||||
\input{conclusion}
|
||||
\addcontentsline{toc}{chapter}{Заключение}
|
||||
|
||||
\input{sources}
|
||||
|
17
sources.tex
@ -4,28 +4,25 @@
|
||||
\or 07.08.2023% 2
|
||||
\or 09.08.2023% 3
|
||||
\or 19.08.2023% 4
|
||||
\or 17.10.2023% 5
|
||||
\else\@ctrerr\fi
|
||||
}
|
||||
\renewcommand\bibname{Библиографический список}
|
||||
\begin{thebibliography}{00}
|
||||
\addcontentsline{toc}{chapter}{Библиографический список}
|
||||
\bibitem{book:nm-examples} Ахмадиев Ф.Г., Габбасов Ф.Г., Ермолаева Л.Б., Маланичев И.В. Численные методы. Примеры и задачи. Учебно-методическое пособие по курсам «Информатика» и «Вычислительная математика». -- Казань:
|
||||
КГАСУ, 2017. -- 107 с.
|
||||
\bibitem{book:bahvalov} Бахвалов~Н.~С., Жидков~Н.~П.,
|
||||
Кобельков~Г.~М. Численные методы. -- 7-е изд. -- М.: БИНОМ. Лаборатория знаний,
|
||||
2011. -- 636 с., c илл. -- (Классический университетский учебник).
|
||||
\bibitem{book:nm-examples} Ахмадиев Ф.Г., Габбасов Ф.Г., Ермолаева Л.Б., Маланичев И.В. Численные методы. Примеры и задачи. Учебно-методическое пособие по курсам «Информатика» и «Вычислительная математика». -- Казань: КГАСУ, 2017. -- 107 с.
|
||||
\bibitem{book:bahvalov} Бахвалов~Н.~С., Жидков~Н.~П., Кобельков~Г.~М. Численные методы. -- 7-е изд. -- М.: БИНОМ. Лаборатория знаний, 2011. -- 636 с., c илл. -- (Классический университетский учебник).
|
||||
\bibitem{links:matplotlib} Документация модуля pyplot библиотеки matplotlib [Электронный ресурс] -- URL:~\url{https://matplotlib.org/stable/api/pyplot_summary.html} (\LiteratureAccessDate[5]).
|
||||
\bibitem{book:levitin} Левитин~A.~В. Алгоритмы: введение в разработку и анализ. -- Пер.~с~англ. -- М.:Издательский~дом~"Вильяме", 2006. -- 576 с., с ил.
|
||||
\bibitem{book:lectures} Письменный~Д.~Т. Конспект лекций по высшей математике. 2 часть. -- М.: Рольф, 2000. -- 256 с., с илл.
|
||||
\bibitem{article:fehlberg} Classical Fifth-, Sixth-, Seventh-, and Eighth-Order Runge-Kutta Formulas with Stepsize Control / Fehlberg E. // NASA technical report 287 -- 1968. -- P.~82
|
||||
\bibitem{links:numpy} Numpy. Официальный сайт проекта [Электронный ресурс] -- URL:~\url{https://numpy.org/} (\LiteratureAccessDate[2]).
|
||||
\bibitem{links:numpy_doc} Numpy API Reference [Электронный ресурс] -- URL:~\url{https://numpy.org/doc/stable/reference/index.html} (\LiteratureAccessDate[3]).
|
||||
\bibitem{links:PEP465} PEP 465 -- A dedicated infix operator for matrix multiplication [Электронный ресурс] -- URL:~\url{A dedicated infix operator for matrix multiplication} (\LiteratureAccessDate[4]).
|
||||
\bibitem{links:python} Python. Официальный сайт проекта [Электронный ресурс] -- URL:~\url{https://www.python.org/} (\LiteratureAccessDate).
|
||||
\bibitem{links:bhatia} Positive definite matrices / R. Bhatia // Princeton Series in Applied Mathematics -- 2007.
|
||||
\bibitem{links:python} Python. Официальный сайт проекта [Электронный ресурс] -- URL:~\url{https://www.python.org/} (\LiteratureAccessDate).
|
||||
\bibitem{links:scipy} Scipy. Официальный сайт проекта [Электронный ресурс] -- URL:~\url{https://scipy.org/} (\LiteratureAccessDate[2]).
|
||||
\bibitem{links:scipy_doc} Scipy API Reference [Электронный ресурс] -- URL:~\url{https://docs.scipy.org/doc/scipy/reference/index.html} (\LiteratureAccessDate[3]).
|
||||
\bibitem{links:tiobe_index} TIOBE. Официальный сайт проекта
|
||||
[Электронный ресурс] -- URL:~\url{https://www.tiobe.com/tiobe-index/} (\LiteratureAccessDate).
|
||||
\bibitem{journal:cartwright} Simpson's Rule Cumulative Integration with MS Excel and Irregularly-spaced Data / Cartwright, Kenneth V. // Journal of Mathematical Sciences and Mathematics Education. -- 2017. -- Vol.~12~(2) -- P.~1-9.
|
||||
\bibitem{article:fehlberg} Classical Fifth-, Sixth-, Seventh-, and Eighth-Order Runge-Kutta Formulas with Stepsize Control / Fehlberg E. // NASA technical report 287 -- 1968.
|
||||
-- P.~82
|
||||
\bibitem{links:tiobe_index} TIOBE. Официальный сайт проекта [Электронный ресурс] -- URL:~\url{https://www.tiobe.com/tiobe-index/} (\LiteratureAccessDate).
|
||||
\end{thebibliography}
|
||||
|