Last active
April 3, 2019 10:44
-
-
Save zhanghuimeng/2aab9648a0e3d0366c8378589846a2de to your computer and use it in GitHub Desktop.
数值分析实验报告模板
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <ctime> | |
#include <iomanip> | |
using namespace std; | |
int main() | |
{ | |
// 你好,世界! | |
cout << "Hello World" << endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ti yi | |
1 33.40 | |
1.5 79.50 | |
2 122.65 | |
2.5 159.05 | |
3 189.15 | |
3.5 214.15 | |
4 238.65 | |
4.5 252.2 | |
5 267.55 | |
5.5 280.50 | |
6 296.65 | |
6.5 301.65 | |
7 310.40 | |
7.5 318.15 | |
8 325.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% !Mode:: "TeX:UTF-8" | |
\documentclass{article} | |
\usepackage[hyperref, UTF8]{ctex} | |
\usepackage[dvipsnames]{xcolor} | |
\usepackage{geometry} | |
\usepackage{amsmath} | |
\usepackage{amsfonts} | |
\usepackage{listings} | |
\usepackage{pgfplotstable} | |
\usepackage{pgfplots} | |
\usepackage{fontspec} | |
\usepackage{booktabs} % 表格上的不同横线 | |
\setmonofont[Mapping={}]{Consolas} %英文引号之类的正常显示,相当于设置英文字体 | |
\setsansfont{Consolas} %设置英文字体 Monaco, Consolas, Fantasque Sans Mono | |
%\setmainfont{Consolas} %设置英文字体 | |
\definecolor{mygreen}{rgb}{0,0.6,0} | |
\definecolor{mygray}{rgb}{0.5,0.5,0.5} | |
\definecolor{mymauve}{rgb}{0.58,0,0.82} | |
\lstset{ % | |
backgroundcolor=\color{white}, % choose the background color | |
basicstyle=\footnotesize\ttfamily, % size of fonts used for the code | |
columns=fullflexible, | |
breaklines=true, % automatic line breaking only at whitespace | |
captionpos=b, % sets the caption-position to bottom | |
tabsize=4, | |
backgroundcolor=\color[RGB]{245,245,244}, % 设定背景颜色 | |
commentstyle=\color{mygreen}, % comment style | |
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code | |
keywordstyle=\color{blue}, % keyword style | |
stringstyle=\color{mymauve}\ttfamily, % string literal style | |
showstringspaces=false, % 不显示字符串中的空格 | |
frame=none, | |
rulesepcolor=\color{red!20!green!20!blue!20}, | |
% identifierstyle=\color{red}, | |
language=c++, | |
} | |
% 设置hyperlink的颜色 | |
\newcommand\myshade{85} | |
\colorlet{mylinkcolor}{violet} | |
\colorlet{mycitecolor}{YellowOrange} | |
\colorlet{myurlcolor}{Aquamarine} | |
\hypersetup{ | |
linkcolor = mylinkcolor!\myshade!black, | |
citecolor = mycitecolor!\myshade!black, | |
urlcolor = myurlcolor!\myshade!black, | |
colorlinks = true, | |
} | |
\title{数值分析实验报告模板} | |
\author{张慕晖} | |
\begin{document} | |
\maketitle | |
\section{实验题目} | |
\subsection{1-3} | |
编程观察无穷级数 | |
$$\sum_{n=1}^{\infty}\frac{1}{n}$$ | |
的求和计算. | |
\begin{description} | |
\item[(1)] 采用IEEE单精度浮点数,观察当n为何值时求和结果不再变化,将它与理论分析的结论进行比较. | |
\item[(2)] 用IEEE双精度浮点数计算(1)中前n项的和,评估IEEE单精度浮点数计算结果的误差. | |
\item[(3)] 如果采用IEEE双精度浮点数,估计当n为何值时求和结果不再变化,这在当前做实验的计算机上大概需要多长的计算时间? | |
\end{description} | |
\newpage | |
\subsection{2-2} | |
编程实现阻尼牛顿法.要求:\textcircled{1}设定阻尼因子的初始值$\lambda_{0}$及解的误差阈值$\epsilon$;\textcircled{2}阻尼因子$\lambda$用逐次折半法更新;\textcircled{3}打印每个迭代步的最终$\lambda$值及初始解.用所编程序求解: | |
\begin{description} | |
\item[(1)] $x^3-x-1=0$,取$x_{0}=0.6$. | |
\item[(2)] $-x^3+5x=0$,取$x_{0}=1.2$. | |
\end{description} | |
\newpage | |
\subsection{3-6} | |
编程实现Hilbert矩阵$\boldsymbol{H_{n}}$,以及n维向量$\boldsymbol{b}=\boldsymbol{H_{n}x}$,其中,$\boldsymbol{x}$为所有分量都是1的向量. 用Cholesky分解算法求解方程$\boldsymbol{H_{n}x} = \boldsymbol{b}$,得到近似解$\boldsymbol{\hat{x}}$,计算残差$\boldsymbol{r}=\boldsymbol{b} - \boldsymbol{H_{n}\hat{x}}$和误差$\Delta \boldsymbol{x} = \boldsymbol{\hat{x}} - \boldsymbol{x}$的$\infty$-范数. | |
\begin{description} | |
\item[(1)] 设n=10,计算${|| \boldsymbol{r} ||}_{\infty}$、${|| \Delta \boldsymbol{x} ||}_{\infty}$. | |
\item[(2)] 在右端项上施加$10^{-7}$的扰动然后解方程组,观察残差和误差的变化情况. | |
\item[(3)] 改变n的值为8和12,求解相应的方程,观察${|| \boldsymbol{r} ||}_{\infty}$、${|| \Delta \boldsymbol{x} ||}_{\infty}$的变化情况. 通过实验说明了什么问题? | |
\end{description} | |
注:Hilbert矩阵$\boldsymbol{H_{n}}$的定义如下: | |
\begin{equation} | |
\label{hilbert} | |
\boldsymbol{H_n} | |
=\begin{bmatrix} | |
1 & \frac{1}{2} & \cdots\ & \frac{1}{n}\\ | |
\frac{1}{2} & \frac{1}{3} & \cdots\ & \frac{1}{n+1}\\ | |
\vdots & \vdots & \ddots & \vdots \\ | |
\frac{1}{n} & \frac{1}{n+1} & \cdots\ & \frac{1}{2n-1}\\ | |
\end{bmatrix} | |
\end{equation} | |
\newpage | |
\subsection{4-1} | |
考虑10阶Hilbert矩阵(见\ref{hilbert})作为系数阵的方程组 | |
$$\boldsymbol{Ax}=\boldsymbol{b}$$ | |
其中,$\boldsymbol{A}$的元素$a_{ij}=\frac{1}{i+j-1}$,$\boldsymbol{b}={[1, 1/2, ..., 1/10]}^T$.取初始解$\boldsymbol{x}^{(0)}=\boldsymbol{0}$,编写程序用Jacobi与SOR迭代法求解该方程组,将${||\boldsymbol{x}^{(k+1)} - \boldsymbol{x}^{(k)} ||}_{\infty} < 10^{-4}$作为终止迭代的判据. | |
\begin{description} | |
\item[(1)] 分别用Jacobi与SOR($\omega = 1.25$)迭代法求解,观察收敛情况. | |
\item[(2)] 改变$\omega$的值,试验SOR迭代法的效果,考察解的准确度. | |
\end{description} | |
\newpage | |
\subsection{5-1} | |
用幂法求下列矩阵按模最大的特征值$\lambda_1$及其对应的特征向量$\boldsymbol{x_1}$,使$|(\lambda_1)_{k+1} - (\lambda_1)_{k}| < 10^{-5}$. | |
\begin{description} | |
\item[(1)] | |
$ | |
\boldsymbol{A}=\begin{bmatrix} | |
5 & -4 & 1\\ | |
-4 & 6 & -1\\ | |
1 & -4 & 7\\ | |
\end{bmatrix} | |
$ | |
\item[(2)] | |
$ | |
\boldsymbol{B}=\begin{bmatrix} | |
25 & -41 & 10 & -6\\ | |
-41 & 68 & -17 & 10\\ | |
10 & -17 & 5 & -3\\ | |
-6 & 10 & -3 & 2\\ | |
\end{bmatrix} | |
$ | |
\end{description} | |
\newpage | |
\subsection{6-3} | |
对物理实验中所得下列数据\\ | |
\begin{tabular}{|c||c|c|c|c|c|c|c|c|} | |
\hline | |
$t_i$ & 1 & 1.5 & 2 & 2.5 & 3.0 & 3.5 & 4 & 4.5 \\\hline | |
$y_i$ & 33.40 & 79.50 & 122.65 & 159.05 & 189.15 & 214.15 & 238.65 & 252.2 \\\hline | |
\hline | |
$t_i$ & 5 & 5.5 & 6 & 6.5 & 7 & 7.5 & 8 & \\\hline | |
$y_i$ & 267.55 & 280.50 & 296.65 & 301.65 & 310.40 & 318.15 & 325.15 & \\\hline | |
\end{tabular} | |
\begin{description} | |
\item[(1)] 用公式$y=a+bt+ct^2$做直线拟合. | |
\item[(2)] 用指数函数$y=ae^{bt}$做曲线拟合. | |
\item[(3)] 比较上述两条拟合曲线,哪条更好? | |
\end{description} | |
\begin{center} | |
\begin{tikzpicture} | |
\begin{axis}[ | |
xlabel = $t_i$, | |
ylabel = {$y_i$}, | |
xmin = 0, xmax = 10, | |
only marks | |
] | |
\addplot table [y=yi, x=ti] {data.dat}; | |
\end{axis} | |
\end{tikzpicture} | |
\end{center} | |
\newpage | |
\section{解题思路} | |
\section{实验结果和结论} | |
\section{实验心得体会} | |
\section{源代码} | |
\lstinputlisting[language=c++]{1-3.cpp} | |
\begin{thebibliography}{9} | |
\bibitem{zhm} | |
zhm, | |
\emph{zhm's report template}, | |
2017. | |
\end{thebibliography} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment