Centered vs aligned equations

aligncenterintegralproof-package

I was writing a research paper and did some proof. I am not happy with how the equations are placed in the pdf. Some of them are in the center, and some of them are far left of the page.
There are three issues here and queries about the best way to organize the paper.

1- what is the best to either center the equations or use align? I like the equations to be in the center.

2- The u-substitution box is written in a new line where I would prefer to be placed far right of the equation ( see the code for better understanding)

3- when using \begin{proof}, the shaded square is not placed at the end of the proof.

Attached is my code, any suggestions or help are greatly appreciated.\

\documentclass[12pt]{article}%For type of paper
\usepackage{authblk}%For author commands
\usepackage{setspace}% For double space
\doublespacing% For double space
\usepackage{subeqnarray} % For number equations (1a), (1b) etc.
\usepackage{graphicx,epstopdf} % For including graphics
\usepackage[framed , numbered]{matlab-prettifier}% For MATLAB code
\usepackage{amssymb}% For ams math, symbol packages
\usepackage{amsmath} % For more ams
\usepackage{amsthm}
\usepackage{xcolor}
\usepackage{bigstrut}
\usepackage{tikz}
\renewcommand{\qedsymbol}{$\blacksquare$}
\usepackage{nccmath}% For adding Mathematical commands
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page margins as needed
\newcommand{\diff}{\mathop{}\!d}
\newcommand{\innerp}[2]{\left\langle #1 \vert #2 \right\rangle}
\newcommand\intpp{\int_{-\pi}^{\pi}} % handy shortcut macro
\begin{document}
\subsection{Partial Sum of Fourier Series}
After we found the coefficients of Fourier series, the partial sum of Fourier series is defined on interval [$-\pi$,$ \pi $]
\begin{equation}
\mathbf{S_N(x) = \frac{1}{2} \, a_{0} + \sum_{n=1}^{N} \left[ 
   a_{n}\,\boldsymbol{\cos} \left( \boldsymbol\,n\,x \right) +
   b_{n} \,\boldsymbol{\sin} \left( \boldsymbol\,n\,x \right) \right] } ,\quad\textrm{where } N<\infty
\end{equation}
Referring back to the coefficients we proved in previous Section \ref{subsection:4.1},and Sub-subsection \ref{subsubsection:4.4.2} , we can now show the partial sum as:
\begin{enumerate}
\item[[A]]
$$ S_N(x) = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x+t)\frac{sin\Big((N+\frac{1}{2}t)\Big)}{\sin(\frac{1}{2}t)} dt$$ 
If we take the 2 from the fraction outside the integral, we will get the Dirichlet Kernel 
$$ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x+t)D_N(t)dt , \quad\textrm{where } D_N(t)\textrm{ is the Dirichlet Kernel }   $$ 
Notice here we integrating from $-\pi$ to $\pi$. So, we also need to proof the integration from 0 to $\pi$ as follows:
\item[[B]] 
$$ S_N(x) = \frac{1}{2\pi}\int_{0}^{\pi}\Big[f(x+t)+f(x-t)\Big]\frac{\sin\big((N+\frac{1}{2})t\big)}{\sin(\frac{1}{2}t)} dt $$
$$ = \frac{1}{\pi}\int_{0}^{\pi}\Big[f(x+t)+f(x-t)\Big]D_N(t)dt $$
\end{enumerate}

\begin{proof} For part A, we can refer back to Section \ref{subsection:4.4}. We take some part of the partial sum which we go from 1 to N. 
$$ a_n\cos(nx)+b_n\sin(nx) $$
So, if we put in the Fourier series coefficients for $ a_n$ and $b_n$, we plug them in and get:
$$ = \Big[\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos(nt)dt\Big]\cos(nx)+\Big[\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\sin(nt)dt\Big]\sin(nx) $$
Since the integrals go from $-\pi$ to $ \pi $, we can factor out the $\frac{1}{\pi}$ and $f(t)$. Then we get:
$$ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\Big[\cos(nt)\cos(nx)+\sin(nt)\sin(nx)\Big]dt $$
So this integral can be reduced by using trig identities we covered in Section \ref{subsection:4.2}.
$$ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos\big(n(t-x)\big)dt $$
Then, when we put those back to the partial sum, we get:
$$ = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(t)dt+\frac{1}{\pi}\sum_{n=1}^{N}\int_{-\pi}^{\pi}f(t)\cos\big(n(t-x)\big)dt $$
We can combine all integrals.We get:
$$ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\Big[\frac{1}{2}+\sum_{n=1}^{N}\cos\big(n(t-x)\big)\Big]dt $$
We can instantly write the formula by referring back to Section \ref{subsection:4.5} as:\\
$\begin{aligned}[t]
\\&= \frac{1}{\pi}\displaystyle\intpp f(t)D_N(t-x)\,dt \\
&  \qquad
   \textcolor{red}{\textup{Substitution}}
   \quad
   \boxed{\begin{aligned}
               u&=t-x,\\
              du&=dt
          \end{aligned}} \\
&= \frac{1}{\pi}\int_{-\pi-x}^{\pi-x}f(x+u)D_N(u)\,du \\
&= \frac{1}{\pi}\intpp f(x+t)D_N(t)\,dt \\
&= \frac{1}{2\pi}\intpp f(x+t)\,
   \frac{\sin\bigl((N+\frac{1}{2})t\bigr)}{\sin\bigl(\frac{1}{2}t\bigr)}\,dt 
   \qquad\qedhere \\
&= \frac{1}{\pi}\int_{-\pi-x}^{\pi-x}f(x+u)D_N(u)du = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x+t)D_N(t)dt 
&= \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x+t)\frac{\sin\big((N+\frac{1}{2})t\big)}{\sin(\frac{1}{2}t)}dt 
\end{aligned}$
\end{proof}
\begin{proof} For part B, we want to restrict the integral from 0 to $\pi $. We begin by partial sum.
$$ S_N(x) = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x+t)D_N(t)dt $$
$\begin{aligned}[t]
\\&= \frac{1}{\pi}\int_{0}^{\pi}f(x+t)D_N(t)dt + \frac{1}{\pi}\int_{-\pi}^{0}f(x+t)D_N(t)dt \\
&  \qquad
   \textcolor{red}{\textup{Substitution}}
   \quad
   \boxed{\begin{aligned}
               u&=-t,\\
              du&=-dt
          \end{aligned}} \\
&= \frac{1}{\pi}\int_{0}^{\pi}f(x+t)D_N(t)dt + \frac{-1}{\pi}\int_{\pi}^{0}f(x-u)D_N(u)du\\
&= \frac{1}{\pi}\int_{0}^{\pi}f(x+t)D_N(t)dt + \frac{1}{\pi}\int_{\pi}^{0}f(x-t)D_N(t)dt\\
&= \frac{1}{\pi}\int_{0}^{\pi}\Big[f(x+t)+f(x-t)\Big]\frac{\sin\big((N+\frac{1}{2})t\big)}{\sin(\frac{1}{2}t)}\cdot dt\\
\end{aligned}$
\end{proof}
\end{document}

Best Answer

Some general comments first.

  • $$ should not be used in latex,
  • \boldsymbol\, is a bold thin space??
  • \item[[A]] has optional argument [A which is the item label, followed by ] which is the start of the text, perhaps you want \item[{[A]}]
  • the final block is left aligned as you use $\begin{aligned}[t] rather than a displayed \begin{align}
  • You define \diff with a spaced d but you just use dt in your equations
  • in \frac{sin\Big( sin should be \sin and \Big should be \Bigl
  • \displaystyle isn't neded in aligned (or align) as it is already in display style

An initial cut at addressing these points is

enter image description here

\documentclass[12pt]{article}%For type of paper
\usepackage{authblk}%For author commands
\usepackage{setspace}% For double space
\doublespacing% For double space
\usepackage{subeqnarray} % For number equations (1a), (1b) etc.
\usepackage{graphicx} % For including graphics
\usepackage[framed , numbered]{matlab-prettifier}% For MATLAB code
\usepackage{amssymb}% For ams math, symbol packages
\usepackage{amsmath} % For more ams
\usepackage{amsthm}
\usepackage{xcolor}
\usepackage{bigstrut}
\usepackage{tikz}
\renewcommand{\qedsymbol}{$\blacksquare$}
\usepackage{nccmath}% For adding Mathematical commands
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page margins as needed
\newcommand{\diff}{\mathop{}\!d}
\newcommand{\innerp}[2]{\left\langle #1 \vert #2 \right\rangle}
\newcommand\intpp{\int_{-\pi}^{\pi}} % handy shortcut macro
\begin{document}
\subsection{Partial Sum of Fourier Series}
After we found the coefficients of Fourier series, the partial sum of Fourier series is defined on interval [$-\pi$,$ \pi $]
\boldmath
\begin{equation}
\mathrm{S}_N(x) = \frac{1}{2}  a_{0} + \sum_{n=1}^{N} \left[ 
   a_{n}\cos ( n x ) +
   b_{n} \sin (nx) \right]  ,\quad\textrm{where } N<\infty
\end{equation}
\unboldmath
Referring back to the coefficients we proved in previous Section \ref{subsection:4.1},and Sub-subsection \ref{subsubsection:4.4.2} , we can now show the partial sum as:
\begin{enumerate}
\item[{[A]}]
\[ S_N(x) = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x+t)\frac{sin\Big((N+\frac{1}{2}t)\Big)}{\sin(\frac{1}{2}t)} \diff t\] 
If we take the 2 from the fraction outside the integral, we will get the Dirichlet Kernel 
\[ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x+t)D_N(t)\diff t , \quad\textrm{where } D_N(t)\textrm{ is the Dirichlet Kernel }   \] 
Notice here we integrating from $-\pi$ to $\pi$. So, we also need to proof the integration from 0 to $\pi$ as follows:
\item[[B]] 
\[ S_N(x) = \frac{1}{2\pi}\int_{0}^{\pi}\Bigl[f(x+t)+f(x-t)\Bigr]\frac{\sin\big((N+\frac{1}{2})t\big)}{\sin(\frac{1}{2}t)} \diff t \]
\[ = \frac{1}{\pi}\int_{0}^{\pi}\Bigl[f(x+t)+f(x-t)\Bigr]D_N(t)\diff t \]
\end{enumerate}

\begin{proof} For part A, we can refer back to Section \ref{subsection:4.4}. We take some part of the partial sum which we go from 1 to N. 
\[ a_n\cos(nx)+b_n\sin(nx) \]
So, if we put in the Fourier series coefficients for $ a_n$ and $b_n$, we plug them in and get:
\[ = \Big[\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos(nt)\diff t\Big]\cos(nx)+\Big[\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\sin(nt)\diff t\Big]\sin(nx) \]
Since the integrals go from $-\pi$ to $ \pi $, we can factor out the $\frac{1}{\pi}$ and $f(t)$. Then we get:
\[ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\Big[\cos(nt)\cos(nx)+\sin(nt)\sin(nx)\Big]\diff t \]
So this integral can be reduced by using trig identities we covered in Section \ref{subsection:4.2}.
\[ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos\big(n(t-x)\big)\diff t \]
Then, when we put those back to the partial sum, we get:
\[ = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(t)\diff t+\frac{1}{\pi}\sum_{n=1}^{N}\int_{-\pi}^{\pi}f(t)\cos\big(n(t-x)\big)\diff t \]
We can combine all integrals.We get:
\[ = \frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\Bigl[\frac{1}{2}+\sum_{n=1}^{N}\cos\bigl(n(t-x)\bigl)\Bigr]\diff t \]
We can instantly write the formula by referring back to Section \ref{subsection:4.5} as:
\begin{align}
&= \frac{1}{\pi}\intpp f(t)D_N(t-x)\,\diff t \\
&  \qquad
   \textcolor{red}{\textup{Substitution}}
   \quad
   \boxed{\begin{aligned}
               u&=t-x,\\
              du&=\diff t
          \end{aligned}} \\
&= \frac{1}{\pi}\int_{-\pi-x}^{\pi-x}f(x+u)D_N(u)\diff uu \\
&= \frac{1}{\pi}\intpp f(x+t)D_N(t)\,\diff t \\
&= \frac{1}{2\pi}\intpp f(x+t)\,
   \frac{\sin\bigl((N+\frac{1}{2})t\bigr)}{\sin\bigl(\frac{1}{2}t\bigr)}\diff t 
   \qquad\qedhere \\ % why qed here?
&= \frac{1}{\pi}\int_{-\pi-x}^{\pi-x}f(x+u)D_N(u)\diff u \\
&= \frac{1}{\pi}\int_{-\pi}^{\pi}f(x+t)D_N(t)\diff t \\
&= \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x+t)\frac{\sin\big((N+\frac{1}{2})t\bigr)}{\sin(\frac{1}{2}t)}\diff t 
\end{align}
\end{proof}
\begin{proof} For part B, we want to restrict the integral from 0 to $\pi $. We begin by partial sum.
\begin{align}
 S_N(x) &= \frac{1}{\pi}\int_{-\pi}^{\pi}f(x+t)D_N(t)\diff t \\
&= \frac{1}{\pi}\int_{0}^{\pi}f(x+t)D_N(t)\diff t + \frac{1}{\pi}\int_{-\pi}^{0}f(x+t)D_N(t)\diff t \\
&  \qquad
   \textcolor{red}{\textup{Substitution}}
   \quad
   \boxed{\begin{aligned}
               u&=-t,\\
              du&=-\diff t
          \end{aligned}} \\
&= \frac{1}{\pi}\int_{0}^{\pi}f(x+t)D_N(t)\diff t + \frac{-1}{\pi}\int_{\pi}^{0}f(x-u)D_N(u)du\\
&= \frac{1}{\pi}\int_{0}^{\pi}f(x+t)D_N(t)\diff t + \frac{1}{\pi}\int_{\pi}^{0}f(x-t)D_N(t)\diff t\\
&= \frac{1}{\pi}\int_{0}^{\pi}\Bigl[f(x+t)+f(x-t)\Bigr]\frac{\sin\bigl((N+\frac{1}{2})t\bigr)}{\sin(\frac{1}{2}t)}\cdot \diff t
\end{align}
\end{proof}
\end{document}
Related Question