0

I'm relatively new to Latex and have so far been able to get by by searching around, but the code I'm currently trying to implement is doing some stuff that I can't predict in the slightest. The .tex file is as follows:

\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}

which outputs the following visual: enter image description here

I'm not quite certain why the instance of split in Question 1.B is aligning like that, given that it worked fine in Question 1.A. As an aside, if there is a way such that instead of having an entire set of steps be notified by the single number, I could have do 7.1, 7.2, 7.3 (such as Question 1A), that would be greatly appreciated.

1
  • Ordinarily, \split has an alignment point indicated by &. In the absence of such a point, all the lines will be aligned at the right, and the group in Question 1.B contains one very long line, which has the effect of shifting everything else to the right. – barbara beeton Oct 13 '20 at 22:38
1

Instead split I would rather use gathered. For text in derivation is more appropriate to use \intertext and 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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.