我对 Latex 还比较陌生,到目前为止,我只能通过四处搜索来解决问题,但我目前尝试实现的代码正在做一些我无法预测的事情。.tex 文件如下:
\documentclass[a4paper,11pt]{article}
\usepackage{fancyhdr,graphics,graphicx,xy, titling}
\usepackage{ifthen}
\usepackage{amssymb,amsmath,mathtools,bm, amsthm}
\title{\vspace{50mm}\textbf{Assignment 5}: Question 1}
\author{Example Name : ID 260847409}
\date{October 13, 2020}
\pagestyle{fancy}
\setlength{\headheight}{15pt}
\lhead{Example Name}
\chead{Question 1}
\rhead{Student ID: 260847409}
\cfoot{\thepage}
\usepackage{etoolbox}
\AtBeginEnvironment{gather}{\setcounter{equation}{0}}
%%%%%%%%%% START OF MAIN DOCUMENT %%%%%%
\begin{document}
\begin{titlepage}
\maketitle
\thispagestyle{empty}
\end{titlepage}
\textbf{Question 1.A}
\begin{gather}
a_{n+1} = 4a_n-3a_{n-1} \text{ where: $a_0 = 0$ and $a_1 = 1$} \\
a_{n+1} - 4a_n + 3a_{n-1} = 0 \\
\text{Substitute $a_n$ for $q^n$: } q^2 -4q + 3 = 0 \\
(q^2 - q)+(-3q + 3) = 0 \\
q(q-1) -3(q-1) \\
(q-3)(q-1) \text{ so $q = 1, q = 3$} \\
\begin{split}
\\ a_n = a(1)^n +b(3)^n \\
n = 0: a + b = 0 \\
n = 1: a(1) + b(3) = 1 \\
\end{split} \\
\begin{split} \\
n = 0: a + b = 0 \\
n = 1: a + 3b = 1 \\
-2b = -1 \\
b = 0.5 \\
a + 0.5 = 0 \\
a = - 0.5 \\ \\
\end{split} \\
a_n = -0.5 + 0.5(3)^n
\end{gather}
\newpage
\textbf{Question 1.B}
\begin{gather}
b_{n+1} = 4b_n - 4b_{n-1} \text{ where: $b_0 = 1$ and $b_1 = 1$} \\
b_{n+1} - 4b_n + 4b_{n-1} = 0 \\
\text{Substitute $b_n$ for $q^n$: } q^2 -4q + 4 = 0 \\
(q-2)^2 = 0, \text{ so $q = 2$} \\
\begin{split} \\
\text{Take the derivative of the original equation to find new recurrence:} \\
\text{Derivative of } q^{n+1}-4q^n+4q^{n-1} \\
(n+1)q^n-4nq^{n-1}+4(n-1)q^{n-2} \\
(q^n - 4q^{n-1} + 4q^{n-2}) + (nq^n - 4((n-1)q^{n-1}) + 4((n-2)q^{n-2})) \\
n*2^n = 4(n-1)2^{n-1}-4(n-2)2^{n-2} \\ \\
\end{split} \\
\text{Therefore: $P_n=2^n$ and $Q_n = n*2^n$} \\
\end{gather}
\end{document}
我不太清楚为什么问题 1.B 中的拆分实例会这样对齐,因为它在问题 1.A 中运行良好。顺便说一句,如果有一种方法可以代替通过单个数字通知整个步骤集,我可以执行 7.1、7.2、7.3(例如问题 1A),那将不胜感激。
答案1
split
我宁愿使用。gathered
对于文本的推导,更适合使用\intertext
和shortintertext
:
\documentclass[a4paper,11pt]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{15pt}
\lhead{Example Name}
\chead{Question 1}
\rhead{Student ID: 260847409}
\cfoot{\thepage}
\usepackage{graphicx, xy}
\usepackage{ifthen}
\usepackage{mathtools, amssymb, amsthm, bm}
\usepackage{titling}
\title{\vspace{50mm}\textbf{Assignment 5}: Question 1}
\author{Example Name : ID 260847409}
\date{October 13, 2020}
\usepackage{etoolbox}
\AtBeginEnvironment{gather}{\setcounter{equation}{0}}
%%%%%%%%%% START OF MAIN DOCUMENT %%%%%%
\begin{document}
\begin{titlepage}
\maketitle
\thispagestyle{empty}
\end{titlepage}
\textbf{Question 1.A}
\begin{gather}
a_{n+1} = 4a_n-3a_{n-1} \text{ where: $a_0 = 0$ and $a_1 = 1$} \\
a_{n+1} - 4a_n + 3a_{n-1} = 0 \\
\intertext{Substitute $a_n$ for $q^n$:}
q^2 -4q + 3 = 0 \\
(q^2 - q)+(-3q + 3) = 0 \\
q(q-1) -3(q-1) \\
(q-3)(q-1) \longrightarrow q = 1,\; q = 3 \\[2ex]
\begin{gathered}
a_n = a(1)^n +b(3)^n \\
n = 0: a + b = 0 \\
n = 1: a(1) + b(3) = 1
\end{gathered} \\[2ex]
\begin{gathered}
n = 0: a + b = 0 \\
n = 1: a + 3b = 1 \\
-2b = -1 \\
b = 0.5 \\
a + 0.5 = 0 \\
a = - 0.5 \\
\end{gathered} \\[2ex]
a_n = -0.5 + 0.5(3)^n
\end{gather}
\newpage
\textbf{Question 1.B}
\begin{gather}
b_{n+1} = 4b_n - 4b_{n-1} \text{ where: $b_0 = 1$ and $b_1 = 1$} \\
b_{n+1} - 4b_n + 4b_{n-1} = 0 \\
\intertext{Substitute $b_n$ for $q^n$: }
q^2 -4q + 4 = 0 \\
(q-2)^2 = 0, \text{ so $q = 2$} \\[2ex]
\intertext{Take the derivative of the original equation to find new recurrence. Derivative of $q^{n+1}-4q^n+4q^{n-1}$ is:}
\begin{gathered}
(n+1)q^n-4nq^{n-1}+4(n-1)q^{n-2} \\
(q^n - 4q^{n-1} + 4q^{n-2}) + (nq^n - 4((n-1)q^{n-1}) + 4((n-2)q^{n-2})) \\
n*2^n = 4(n-1)2^{n-1}-4(n-2)2^{n-2}
\end{gathered}
\shortintertext{Therefore:}
P_n=2^n \text{ and } Q_n = n*2^n
\end{gather}
\end{document}