text:
<repo_name>quaffle51/TEE-EM-AH-02-2020<file_sep>/q3c.tex
% !TeX root = ./TMA02.tex
\def\a2b{\alpha^2\beta}
In order to deduce that a first-integral of $\Sv{y}$ is
\[
	4x^5y y^\prime + x^6\lr{y^{\prime2} + \2o3 y^3} = c
\]
where $c$ is a constant use will be made of \nt.\marginnote{See definition~7.1, p.165.}
\[
	\a2b = 1,\quad \alpha=\lr{1+\delta},\quad \textrm{then}\quad \lr{1+\delta}^2\beta=1.
\]
\[
	\Phi = \alpha x = \lr{1+\delta}x = x + \delta x.
\]
\marginnote{HB p.2 Binomial expansion.}[0.8cm]
\[
	\Psi = \beta y = \frac{1}{\lr{1+\delta}^2}y = y-2y\delta\quad \textrm{to first order}.
\]
\[
	\phi =\left. \pderiv{\Phi}{\delta} \right| _{\delta=0} = x,\qquad \psi = \left. \pderiv{\Psi}{\delta} \right| _{\delta=0} = -2y.
\]
\[
	F = x^5\lr{y^{\prime2} - \2o3 y^3},\qquad \pderiv{F}{y^\prime} = 2x^5 y^\prime.
\]
Now making use of \nt\marginnote{HB p.21 c.f. equation $\lr{\textrm{FI}}$.}\marginnote{A first-integral of $\Sv{y}$.}[1.5cm]
\[
	\pderiv{F}{y^\prime}\psi + \lr{F - y^\prime \pderiv{F}{y^\prime}}\phi = constant.
\]
\begin{align*}
	\pderiv{F}{y^\prime}\psi + \lr{F - y^\prime \pderiv{F}{y^\prime}}\phi =& 2x^5 y^\prime\lr{-2y} + \lr{ x^5\lr{y^{\prime2} - \2o3 y^3} - y^\prime 2x^5 y^\prime}x,\\
	=& -4 x^5yy^\prime + x^6\lr{y^{\prime2}-\2o3 y^3 - 2y^{\prime2}} = -c,\\
	=& -4 x^5yy^\prime + x^6\lr{-y^{\prime2}-\2o3 y^3} = -c,\\
	=& 4 x^5yy^\prime + x^6\lr{y^{\prime2}+\2o3 y^3} = c,
\end{align*}
as required.<file_sep>/q1b.tex
% !TeX root = ./TMA02.tex
\def\dxu{\deriv{x}{u}}%
The given functional from part (a) is
\[
	S[y] = \int_a^b \dd x\left(y^2\sinh x -\frac{2y^{\prime 2}}{\sinh x}\right),\quad y(a) = A,\quad y(b) = B,\quad 0< a < b,
\]
In the functional the term $y^\prime$, which is a function of the independent variable $x$, needs to be changed to a function of $u$ which is in turn a function of $x$. Thus, letting the variable $u$ be a function of $x$, i.e. $u=u(x)$, then, using the chain rule to change the independent variable from $x$ to $u$ of $y^\prime(u)$ gives the following expression for $y^\prime$
\[
	y^\prime = \deriv{y}{x} = \deriv{y}{u}\cdot\deriv{u}{x}.
\]
So, if $y^\prime$ in the functional is replaced for the expression above,
\begin{equation*}
\begin{split}
	S[y] =& \int_{x_1=a}^{x_2=b}\deriv{x}{u}\dd u\left(y^2\sinh x-\frac{2}{\sinh x}\left(\deriv{y}{u}\right)^2\left(\deriv{u}{x}\right)^2\right),\\
	S[y] =& \int_{x_1=a}^{x_2=b}\deriv{x}{u}\dd u\left(y^2\sinh x-\frac{2}{\sinh x}\left(\deriv{y}{u}\right)^2\left(\deriv{u}{x}\cdot\deriv{u}{x}\right)\right),\\
	S[y] =& \int_{u_1}^{u_2}\dd u\left(y^2\dxu\sinh x-\frac{2}{\sinh x}\left(\deriv{y}{u}\right)^2\left(\deriv{u}{x}\cdot\deriv{u}{x}\right)\deriv{x}{u}\right),\\
	S[y] =& \int_{u_1}^{u_2}\dd u\left(y^2\dxu\sinh x-\frac{2}{\sinh x}\left(\deriv{y}{u}\right)^2\deriv{u}{x}\right),\\
	S[y] =& \int_{u(a)}^{u(b)}\dd u\left(y^2\dxu\sinh x-2\left[\frac{1}{\sinh x}\cdot\deriv{u}{x}\right]\left(\deriv{y}{u}\right)^2\right).
\end{split}
\end{equation*}
If
\[
	\frac{1}{\sinh x}\cdot\deriv{u}{x} = 1
\]
then
\[
	1 = \sinh x\cdot\deriv{x}{u},
\]
and so
\[
	\dd u = \sinh x \dd x.
\]
Integrating the above
\begin{equation*}
\begin{split}
	u(x) =& \int \dd x \sinh x = \cosh x,\\
	u(x) =& \cosh x.
\end{split}
\end{equation*}
Thus, the functional becomes
\begin{align}
	S[y] =& \int_{\cosh a}^{\cosh b}\dd u \left(y^2 -2\left(\deriv{y}{u}\right)^2\right),\nonumber\\
	\label{eq:1.1}
	S[y] =& \int_{\cosh a}^{\cosh b}\dd u \left(y^2-2\left(y^\prime(u)\right)^2\right),
\end{align}
as required, with $u_1=\cosh a$ and $u_2=\cosh b$.<file_sep>/q1c.tex
% !TeX root = ./TMA02.tex
\def\F{\mathcal{F\xspace}}%
\def\L{\left(}%
\def\R{\right)}%
\def\osu{\L\frac{1}{\sqrt{2}}\cdot u\R}%
Solving for the associated \el for the functional \eqref{eq:1.1}:
\[
	\textrm{Let}\quad \F = y^2 - 2y^{\prime2},
\]
then
\[
	\pderiv{\F}{y^\prime} = -4 y^\prime,
\]
\[
	\deriv{}{u}\L\pderiv{\F}{y^\prime}\R = \deriv{}{u}\L-4 y^\prime\R = -4 y^\dprime,
\]
\[
	\textrm{and}\quad \deriv{\F}{y} = 2 y.
\]
The \el is
\[
	-4\deriv{^2y}{u^2} - 2y = 0,
\]
which after dividing through by $-4$ becomes
\[
	\deriv{^2y}{u^2} +\half y = 0.
\]
The auxiliary equation for the above \el is
\[
	\lambda^2 + \half = 0, \quad \textrm{and the roots are} \quad \lambda_{1,2} = \pm i\frac{1}{\sqrt{2}}.
\]
Hence, the general solution is
\begin{equation}
\label{eq:1.2}
	y = c_1\cos\osu + c_2\sin\osu,
\end{equation}
where, $c_1$ and $c_2$ are arbitrary constants.<file_sep>/q5b.tex
% !TeX root = ./TMA02.tex
\def\y^p2{y^{\prime2}}
\def\F_ypyp{F_{y^\prime y^\prime}}
Jacobi's equation is given by\marginnote{HB p.22.}[0cm]
\[
	\deriv{}{x}\lr{P\,\deriv{u}{x}} - Qu =0,\quad a\leq x \leq b,
\]
where
\[
	P(x) = \pderiv{^2F}{y^{\prime2}} = F_{y^{\prime}y^{\prime}},
\]
and
\[
	Q(x) = \pderiv{^2F}{y^2} - \deriv{}{x}\lr{\psderiv{F}{y}{y^\prime}} = F_{yy} - \deriv{}{x}\lr{F_{yy^\prime}}.
\]
From part~(a)
\begin{equation*}
	F=f(x)\,\,\sqrt[•]{1+y^{\prime2}} = f(x)\,\,\lr{1 + y^{\prime2}}^\half.
\end{equation*}
\[
	F_y =0,\qquad F_{yy} =0,\quad F_{yy^\prime} = 0\quad\textrm{and hence,}\quad Q(x)=0.
\]
The express for $P(x)$ is determined as follows,
\begin{align*}
	F =& f(x)\,\,\lr{1 + y^{\prime2}}^\half.\\
	F_{y^\prime} =& \half f(x)\lr{1 + y^{\prime2}}^{-\half}\,2y^\prime,\\
	F_{y^\prime} =& f(x)\lr{1 + y^{\prime2}}^{-\half}\,y^\prime.
\end{align*}
Using the product rule to take the partial derivative of the express for $F_{y^\prime}$ with respect to $y^\prime$, and to be clear about its derivation,
\[
	\textrm{Let}\quad u = f(x)\lr{1 + y^{\prime2}}^{-\half}\quad\textrm{and}\quad v=y^\prime.
\]
\[
	\pderiv{F_{y^\prime}}{y^\prime} = F_{y^{\prime}y^{\prime}} = u\,\deriv{v}{y^{\prime}} + u\,\deriv{u}{y^{\prime}}.
\]
Then, using the chain rule to obtain the partial derivative of $u$ with respect to $y^\prime$,
\[
	\deriv{u}{\yp} = -\half\,f(x)\lr{1 + \y^p2}^{-\frac{3}{2}}\cdot 2\yp = -f(x)\lr{1 + \y^p2}^{-\frac{3}{2}}\cdot \yp,
\]
and
\[
	\deriv{v}{\yp} = 1.
\]
Thus,
\begin{align*}
	\F_ypyp =& f(x)\lr{1 + \y^p2}^{-\half} + y^\prime\lrs{-f(x)\lr{1 + \y^p2}^{-\frac{3}{2}}\cdot y^{\prime}},\\
	=& f(x)\lr{1 + \y^p2}^{-\half} - f(x)\lr{1 + \y^p2}^{-\frac{3}{2}}\cdot y^{\prime2},\\
	=& \frac{f(x)}{\lr{1 + \y^p2}^{\half}}\lrs{1 - \frac{y^{\prime2}}{\lr{1 + \y^p2}}},\\
	=& \frac{f(x)}{\lr{1 + \y^p2}^{\half}}\lrs{\frac{1}{\lr{1 + \y^p2}}},\\
	=& \frac{f(x)}{\lr{1 + \y^p2}^\frac{3}{2}}.
\end{align*}
Hence, we have
\[
	P(x) = \frac{f(x)}{\lr{1 + \y^p2}^\frac{3}{2}} > 0,\quad\textrm{as}\quad f(x) > 0.
\]
\textcolor{black}{%\marginnote{Addition to my 2019 submission reflecting my Tutor's comments.}%
To determine if conjugate points to $x=a$ exist or not consider the following.
\begin{align*}
	Q(x) = 0\quad\textrm{so }\deriv{}{x}\lr{P(x)\,u^\prime} = 0.\\
	u^\prime = \frac{k}{P(x)}\quad\textrm{and }u(a)=0, u^\prime(a) = 1.\\
	\textrm{Therefore, } k=P(a),\quad\textrm{so }u^\prime =\frac{P(a)}{P(x)} > 0.
\end{align*}
Consequently, $u$ is strictly increasing, so $u(x) > u(a)=0$ for all $x>a$. Thus, $u\neq 0$ on the interval $(a,b]$, which means there are no conjugate points.
}

This shows that the stationary path found in part~(a) gives a weak local minimum (as $P(x) >0$ for all $a\leq x\leq b$) of the functional $S[y]$.<file_sep>/q3.tex
% !TeX root = ./TMA02.tex
\begin{question}

\qpart %(a)
\input{q3a}
%
\qpart %(b)
\input{q3b}
%
\qpart %(c)
\input{q3c}
%
\qpart %(d)
\input{q3d}

\end{question}<file_sep>/q2b.tex
% !TeX root = ./TMA02.tex
Making the linear transformation
\begin{align*}
	z_1 =& y_1 + a y_2,\\
	z_2 = & 2y_1 + y_2
\end{align*}
to the new dependent variables $z_1, z_2$, where $a$ is a constant, the value of $a$ can be found in such a way that the functional can be written as the sum of two functionals, one of which depends only on $z_1$ and the other only on $z_2$ in the following way:
\begin{align}
	z_1 =& y_1 + a y_2,\nonumber\\
	z_1^\prime =& y_1^\prime + a y_2^\prime,\nonumber\\
	\label{eq:2.3}
	y_1^\prime =& z_1^\prime -ay_2^\prime,\quad \textrm{and} \\
	\label{eq:2.4}
	y_2^\prime =& \frac{z_1^\prime-y_1^\prime}{a}.
\end{align}
Similarly,
\begin{align}
	z_2 =& 2y_1 + y_2,\nonumber\\
	z_2^\prime =& 2y_1^\prime + y_2^\prime,\nonumber\\
	\label{eq:2.5}
	y_1^\prime =& \frac{z_2^\prime -y_2^\prime}{2},\quad \textrm{and} \\
	\label{eq:2.6}
	y_2^\prime =& z_2^\prime - 2y_1^\prime.
\end{align}
Equating \eqref{eq:2.3} and \eqref{eq:2.5} gives
\begin{equation}
	\label{eq:2.7}
	z_1^\prime - ay_2^\prime = \frac{z_2^\prime - y_2^\prime}{2},
\end{equation}
and rearranging \eqref{eq:2.7} in terms of $y_2^\prime$ gives,
\begin{equation}
	\label{eq:2.8}
	y_2^\prime = \frac{2z_1^\prime - z_2^\prime}{2a-1}.
\end{equation}
Now equating \eqref{eq:2.4} and \eqref{eq:2.6}
\begin{equation}
	\label{eq:2.9}
	\frac{z_1^\prime - y_1^\prime}{a} = z_2^\prime - 2y_1^\prime,
\end{equation}
and rearranging \eqref{eq:2.9} in terms of $y_1^\prime$ gives,
\begin{equation}
	\label{eq:2.10}
	y_1^\prime = \frac{z_1^\prime - az_2^\prime}{1-2a}.
\end{equation}
What is required is $y_1^{\prime2} + 2y_2^{\prime2}$ in terms of just  $z_1$ and  $z_2$. Thus, from \eqref{eq:2.10}
\begin{align*}
	y_1^{\prime2} = \frac{\left(z_1^\prime - az_2^\prime\right)^2}{\left(1-2a\right)^2} =
	\frac{z_1^{\prime2} - 2az_1^\prime z_2^\prime + a^2 z_2^{\prime2}}{\left(1-2a\right)^2},
\end{align*}
and from \eqref{eq:2.8} after multiplying the numerator and denominator by $-1$ so that the denominator becomes $1-2a$
\begin{align*}
	y_2^{\prime2} = \frac{\left(z_2^\prime - 2z_1^\prime\right)^2}{\left(1-2a\right)^2} = \frac{z_2^{\prime2} -4z_1^\prime z_2^\prime + 4z_1^{\prime2}}{\left(1-2a\right)^2}.
\end{align*}
Therefore,
\begin{align}
	y_1^{\prime2} + 2y_2^{\prime2} =& \frac{z_1^{\prime2} - 2az_1^\prime z_2^\prime + a^2 z_2^{\prime2}}{\left(1-2a\right)^2} + \frac{2\left(z_2^{\prime2} -4z_1^\prime z_2^\prime + 4z_1^{\prime2}\right)}{\left(1-2a\right)^2},\nonumber\\
	\label{eq:2,11}
	=& \frac{9z_1^{\prime2} -2z_1^\prime z_2^\prime\left(a+4\right) + z_2^{\prime2}\left(a^2 + 2\right)}{\left(1-2a\right)^2}.
\end{align}
To eliminate the $z_1^\prime z_2^\prime$ term in \eqref{eq:2,11} set $a+4 = 0$. Thus,
\begin{align}
	y_1^{\prime2} + 2y_2^{\prime2} =& \frac{9z_1^{\prime2} + 18z_2^{\prime2}}{9^2},\nonumber\\
	=& \frac{z_1^{\prime2} + 2z_2^{\prime2}}{9}.
\end{align}
Consequently,
\[
	a = -4,
\]
and is the value of $a$ such that the given functional can be written as the sum of two functionals, one which depends only on $z_1$ and the other only on $z_2$. Thus,
\[
	S\left[z_1,z_2\right] = \frac{1}{9}\Int{}{}{x} z_1^{\prime2} + \frac{1}{9}\Int{}{}{x}\left(2z_2^{\prime2} + 9z_2^2\right).
\]
<file_sep>/q2.tex
% !TeX root = ./TMA02.tex
\begin{question}
\qpart %(a)
\input{q2a}
\qpart %(b)
\input{q2b}
\qpart %(a)
\input{q2c}
\qpart %(b)
\input{q2d}
\end{question}<file_sep>/q3a.tex
% !TeX root = ./TMA02.tex
\def\yp2{y^{\prime2}}%
\def\2o3{\frac{2}{3}}%
\def\func{x^5 \lr{\yp2 - \2o3y^3}}
Let $0 < a < b$ and the given functional is
\[
	S[y] = \Int{a}{b}{x} \func.
\]
So the \el can be determined as follows.
\[
	\textrm{Let,}\quad F = \func, \quad\textrm{then,}
\]
\[
	\pderiv{F}{y^\prime} = 2y^\prime x^5,\quad \pderiv{F}{y} = -\2o3\cdot3y^2x^5 = -2y^2x^5.
\]
\[
	\deriv{}{x}\lr{2y^\prime x^5} = 2y^\prime5x^4 + x^52y^\dprime = 10y^\prime x^4 + 2x^5y^\dprime.
\]
The \el can be written as
\[
	\ELE{F}{x}{y},
\]
therefore, we have
\[
	10y^\prime x^4 + 2x^5y^\dprime + 2y^2x^5 = 0,
\]
which can be simplified to
\[
	\deriv{^2y}{x^2} + \frac{5}{x}\deriv{y}{x} + y^2 = 0,
\]
as required.<file_sep>/q4b.tex
% !TeX root = ./TMA02.tex
The Jacobi equation will be used to determine the nature of this stationary path as follows.\marginnote{HB p.22}[0cm]

Let $n > 1$ be a positive integer.
\[
	F\lr{y,y^\prime} = \lr{y^\prime}^n\e^y.
\]
\[
	P\lr{x} = \pderiv{^2F}{y^{\prime2}} = \pderiv{^2\lr{\lr{y^\prime}^n\e^y}}{y^{\prime^2}},
\]
\[
	\pderiv{F}{y^\prime} = n\lr{y^\prime}^{n-1}\e^y.
\]
\[
	P(x)=\pderiv{^2F}{y^{\prime2}} = n\lr{n-1}\lr{y^\prime}^{n-2}\e^y,
\]
where $y = n\ln\lr{cx + e^{\frac{1}{n}}}$. Therefore,
\[
	y^\prime = \frac{nc}{\lr{cx + e^{\frac{1}{n}}}},\qquad\textrm{where}\quad c=\e^{\frac{A}{n}} - \e^{\frac{1}{n}}.
\]
So,
\begin{align*}
	P(x) =& n(n-1)\lr{\dfrac{nc}{cx + \e^{\frac{1}{n}}}}^{n-2}\e^{ n\ln\lr{cx + e^{\frac{1}{n}}}},\\
		 =& n(n-1)\lr{\dfrac{nc}{cx + \e^{\frac{1}{n}}}}^{n-2}\lr{cx + e^{\frac{1}{n}}}^n,\\
		 =& n(n-1)\lr{\dfrac{nc}{cx + \e^{\frac{1}{n}}}}^{n}\frac{\lr{cx + e^{\frac{1}{n}}}^2\lr{cx + e^{\frac{1}{n}}}^n}{(nc)^2},\\
		 =& n(n-1)\frac{(nc)^n\lr{cx + e^{\frac{1}{n}}}^{2+n}}{(nc)^2\lr{cx + e^{\frac{1}{n}}}^{n}},\\
		 =& n(n-1)(nc)^{n-2}\lr{cx + e^{\frac{1}{n}}}^{2} > 0.
\end{align*}
Note: $c=\e^{\frac{A}{n}} - \e^{\frac{1}{n}} > 0$ because $A>1$, $n>1$, thus, $n(n-1) > 0$ and $nc>0$. The term $\lr{cx + e^{\frac{1}{n}}}^{2} > 0$ regardless of the  terms within the brackets as it is squared.

Thus, if the stationary path $y(x)$ is an extremum then it will be a local minimum.

\[
	Q(x) = \pderiv{^2F}{y^2} - \deriv{}{x}\lr{\psderiv{F}{y}{y^\prime}}.
\]
\[
	F = \lr{y^\prime}^n\e^y,\qquad \pderiv{F}{y}=\lr{y^\prime}^n\e^y,\qquad \pderiv{^2F}{y^2}=\lr{y^\prime}^n\e^y.
\]
\[
	\pderiv{F}{y^\prime} = n\lr{y^\prime}^{n-1}\e^y,\qquad \psderiv{F}{y}{y^\prime} = n\lr{y^\prime}^{n-1}\e^y.
\]
So,
\begin{align*}
	Q(x) =& \lr{y^\prime}^n\e^y - \deriv{}{x}\lr{n\lr{y^\prime}^{n-1}\e^y},\\
	=& \lr{y^\prime}^n\e^y - \lr{n\lr{y^\prime}^{n-1}y^\prime\e^y +\e^yn(n-1)\lr{y^\prime}^{n-2}y^\dprime},\\
	=& \lr{y^\prime}^n\e^y - \lr{n\lr{y^\prime}^{n}\e^y +\e^yn(n-1)\lr{y^\prime}^{n-2}y^\dprime},\\
	=& \e^y\lr{\lr{y^\prime}^n - n\lr{y^\prime}^{n} - n(n-1)\lr{y^\prime}^{n-2}y^\dprime},\\
	=& \e^y\lr{(1-n)\lr{y^\prime}^n - n(n-1)\lr{y^\prime}^{n-2}y^\dprime},\\
	=& \e^y\lr{\lr{y^\prime}^n\lrs{(1-n)-n(n-1)\lr{y^\prime}^{-2}y^\dprime}},\\
	=& \e^y\lr{\lr{y^\prime}^n\lrs{(1-n)-\frac{n(n-1)}{\lr{y^\prime}^{2}}y^\dprime}}.
\end{align*}
Now,
\[
	y^\prime = \frac{nc}{cx + \e^{\frac{1}{n}}},\qquad y^\dprime = -\frac{nc^2}{\lr{cx + \e^{\frac{1}{n}}}^2}.
\]
Substituting into the last equation for $Q(x)$ for $y^\prime$ and $y^\dprime$ gives,
\begin{align*}
	Q(x) =& \e^y\lr{\frac{(nc)^n}{\lr{cx + \e^{\frac{1}{n}}}^n}\lrs{(1-n)-\frac{n(n-1)}{\frac{nc^2}{\lr{cx + \e^{\frac{1}{n}}}^2}}\lr{-\frac{nc^2}{\lr{cx + \e^{\frac{1}{n}}}^2}}}},\\
	=& \e^y\lr{\frac{(nc)^n}{\lr{cx + \e^{\frac{1}{n}}}^n}\lrs{
			(1-n)-\frac{n(n-1)(-nc)^2}{(nc)^2}
	}},\\
	=& \e^y\lr{
			\frac{(nc)^n}{\lr{cx + \e^{\frac{1}{n}}}^n}\lrs{
				(1-n) + (n-1)
			}
	},\\
	=& 0.
\end{align*}
The Jacobi equation is\marginnote{HB p.22}[1.25cm]
\[
	\deriv{}{x}\lr{
		P(x)\deriv{u}{x}
	} - Q(x)u = 0,\quad	u(a) = 0,\quad u^\prime(a) = 1.
\]
Thus,
\[
	P(x)\deriv{u}{x} = k,\quad \textrm{where $k$ is a constant.}
\]
\[
	\deriv{u}{x} =k\frac{1}{P(x)} = k\cdot\frac{\lr{cx+\e^{\frac{1}{n}}}^{-2}}{n(n-1)(nc)^{n-2}},\quad n>1.
\]
\[
	\textrm{Redefining } k,\quad \deriv{u}{x} = k\lr{cx + \e^{\frac{1}{n}}}^{-2}.
\]
\[
	u = k\Int{•}{•}{x}\frac{1}{\lr{cx + \e^{\frac{1}{n}}}^2}.
\]
\[
	\textrm{Let } s = cx + \e^{\frac{1}{n}},\quad \textrm{then } \deriv{s}{x} = c,
\]
\[
	\textrm{and}\quad \deriv{x}{s} = \dfrac{1}{\deriv{s}{x}} = \frac{1}{c}.
\]
\[
\textrm{Thus, } u=k\Int{•}{•}{s} \frac{1}{s^2}\deriv{x}{s} = \frac{k}{c}\Int{•}{•}{s}s^{-2}.
\]
\[
	u = A - \frac{k}{c}s^{-1},\qquad\textrm{where $A$ is a constant.}
\]
Substituting back for $s$ gives, $u=A - \dfrac{k}{c}\dfrac{1}{\lr{cx + \e^{\frac{1}{n}}}}$.

Applying the initial condition $u(0) = 0$ enables the constant $A$ to be found,
\[
	A = \dfrac{k}{c\cdot\e^\frac{1}{n}}.
\]
Hence,
\[
	u(x) = \dfrac{k}{c\cdot\e^\frac{1}{n}} - \dfrac{k}{c}\dfrac{1}{\lr{cx + \e^{\frac{1}{n}}}}.
\]
Differentiating the above expression with respect to $x$ gives,
\[
	u^\prime(x) = (-1)\cdot\lr{-\frac{k}{c}}\cdot\frac{1}{\lr{cx + \e^{\frac{1}{n}}}^2}\cdot c = k\cdot \frac{1}{\lr{cx + \e^{\frac{1}{n}}}^2}.
\]
Applying the initial condition $u^\prime(0)=1$ gives,
\[
	1 = k\cdot \frac{1}{\lr{\e^\frac{1}{n}}^2},\quad \textrm{thus, } k = \e^{\frac{2}{n}}.
\]
Hence,
\begin{align*}
	u(x) = & \frac{k}{c \e^{\frac{1}{n}}} - \frac{k}{c} \frac{1}{\lr{cx + \e^{\frac{1}{n}}}},\quad\textrm{where, } k=\e^{\frac{2}{n}},\\
	u(x) = & \frac{\e^{\frac{2}{n}}}{c \e^{\frac{1}{n}}} - \frac{\e^{\frac{2}{n}}}{c} \frac{1}{\lr{cx + \e^{\frac{1}{n}}}},\\
	u(x) = & \frac{\e^{\frac{1}{n}}}{c} - \frac{\e^{\frac{2}{n}}}{c} \frac{1}{\lr{cx + \e^{\frac{1}{n}}}},
\end{align*}
\begin{align*}
	u(x) = & \frac{\e^{\frac{1}{n}}}{c}\lrs{1 - \frac{\e^{\frac{1}{n}}}{\lr{cx + \e^{\frac{1}{n}}}}},\\
	u(x) = & \frac{\e^{\frac{1}{n}}}{c}\lrs{\frac{cx + \e^{\frac{1}{n}} - \e^{\frac{1}{n}}}{\lr{cx + \e^\frac{1}{n}}}},\\
	u(x) = & \frac{\e^{\frac{1}{n}}}{c}\lrs{\frac{cx}{\lr{cx + \e^\frac{1}{n}}}},\\
	u(x) = & \frac{\e^\frac{1}{n} x}{cx + \e^\frac{1}{n}}.
\end{align*}
Equating $u(x)$ to zero gives,
\begin{align*}
	0 =& \frac{e^\frac{1}{n} x}{cx + \e^\frac{1}{n}},\\
	0 =& \e^\frac{1}{n} x,
\end{align*}
which can only be true when $x=0$.  Therefore, the closed interval $[0,1]$ does not contain points conjugate to the point $x=0$.

From Theorem~8.4:\marginnote{A sufficient condition, Notes, p.185.}[0cm]
\begin{itemize}
  \item The function $y(x)$ satisfies the \el;
  \item Along the curve $y(x), P(x) = F_{y^\prime y^\prime} > 0$ for $0\leq x \leq 1$; and
  \item The closed interval $[0,1]$ contains no points conjugate to the point $x=0$.
\end{itemize}
Hence, the functional has a weak minimum along $y(x)$.
<file_sep>/q2d.tex
% !TeX root = ./TMA02.tex
\def\gm{\dfrac{3}{ \sqrt{2} } }%
\def\g2{\dfrac{9}{2}}
\def\1o9{\frac{1}{9}}%
\def\2o9{\frac{2}{9}}%
\def\4o9{\frac{4}{9}}%
\def\9o2{\frac{9}{2}}%
\def\8o9{\frac{8}{9}}%
\def\32o9{\frac{32}{9}}%
\def\egx{\e^{\gamma x}}%
\def\engx{\e^{-\gamma x}}%
The \el \eqref{eq:2.1} was determined to be
\[
	2y_1^\dprime - 4\left(2y_1+y_2\right) = 0.
\]
Let $\gamma = \gm$ so that $\gamma^2=\g2$, then,
\begin{align*}
	y_1 =& \1o9\left[c_3x + c_4 + 4c_1\e^{\gamma x} + 4c_2\e^{-\gamma x}\right],\\
	y_1^\prime =& \1o9\left[c_3  + 4c_1\gamma\e^{\gamma x} - 4c_2\gamma\e^{-\gamma x}\right],\quad\textrm{and}\\
	y_1^\dprime =&  \1o9\left[4c_1\gamma^2\e^{\gamma x} + 4c_2\gamma^2\e^{-\gamma x}\right].\\\\\
	y_2 =& -\2o9\left[c_3x + c_4-\half c_1\e^{\gamma x} -\half c_2\e^{-\gamma x} \right].
\end{align*}
So,
\begin{align*}
	2y_1^\dprime -4\left(2y_1 + y_2\right) =&\cancelto{1}{\2o9}\left(4c_1\cancelto{1}{\9o2}\e^{\gamma x} + 4c_2\cancelto{1}{\9o2}\e^{-\gamma x}\right)\\
	{}& -\8o9\left(\cancelto{0}{c_3 x} + \cancelto{0}{c_4} + 4c_1\e^{\gamma x} + 4c_2\e^{-\gamma x}\right)\\
	{}& +\8o9\left(\cancelto{0}{c_3 x} + \cancelto{0}{c_4} - \half c_1\e^{\gamma x} - \half c_2\e^{-\gamma x}\right),\\
	=& \cancelto{0}{\left(4c_1\e^{\gamma x} - \32o9c_1\e^{\gamma x}-\4o9c_1\e^{\gamma x}\right)}\\
	{}&  + \cancelto{0}{ \left( 4 c_2 \e^{-\gamma x} - \32o9 c_2 \e^{-\gamma x} - \4o9 c_2 \e^{-\gamma x}\right)},\\
	=& 0.
\end{align*}
Consequently, $\left(y_1,y_2\right)$ satisfies the first \el.

Similarly for the second \el equation.

\el \eqref{eq:2.2} was determined to be
\[
	4y_2^\dprime - 2\left(2y_1+y_2\right) = 0.
\]
\begin{align*}
	y_2 =& -\2o9\left(c_3x + c_4 -\half c_1 \egx -\half c_2 \engx\right), \\
	y_2^\prime =& -\2o9\left(c_3 -\half c_1\gamma\egx + \half c_2 \gamma\engx\right), \\
	y_2^\dprime =& -\2o9\left(-\half c_1\gamma^2 \egx - \half c_2 \gamma^2\engx \right) = \2o9\left(\half c_1\gamma^2 \egx + \half c_2 \gamma^2\engx \right),\quad\textrm{and}\\
	y_1 =& \1o9\left(c_3x + c_4 + 4c_1\egx + 4c_2\engx\right).
\end{align*}
So,
\begin{align*}
	4y_2^\dprime - 2\left(2y_1 + y_2\right) =& \cancelto{2}{\8o9}\left(\cancelto{1}{\half} c_1\cancelto{1}{\9o2}\egx + \cancelto{1}{\half} c_2\cancelto{1}{\9o2}\engx\right)\\
	{}& - \4o9\left(\cancelto{0}{c_3x} + \cancelto{0}{c_4} + 4c_1\egx + 4c_2\engx \right)\\
	{}& + \4o9\left(\cancelto{0}{c_3x} + \cancelto{0}{c_4} -\half c_1\egx -\half c_2\engx \right),\\
	=& \cancelto{0}{2c_1\egx - \frac{16}{9}c_1\egx - \2o9 c_1 \egx}\\
	{}& + 2\cancelto{0}{c_2\engx -\frac{16}{9}c_2\engx - \2o9 c_2\engx},\\
	=& 0.
\end{align*}
Consequently, $\left(y_1,y_2\right)$ satisfies the second \el, too.<file_sep>/q4a.tex
% !TeX root = ./TMA02.tex
The functional is
\[
	\Sv{y} = \Int{0}{1}{x}\lr{y^\prime}^n\e^y,\quad	y(0)=1,\quad y(1) = A >1,
\]
and the integrand $F=\lr{y^\prime}^n\e^y$ is independent of the independent variable, $x$, so that (first-integral),
\[
	y^\prime \deriv{F}{y^\prime} - F = constant,\quad F=\lr{y^\prime}^n\e^y.
\]
\[
	\pderiv{F}{y^\prime} = n\e^y\lr{y^\prime}^{n-1},\quad y^\prime \pderiv{F}{y^\prime} = ne^y\lr{y^\prime}^n.
\]
\[
	\therefore\quad ne^y\lr{y^\prime}^n - \lr{y^\prime}^n\e^y = constant.
\]
\[
	\lr{n-1}\e^y\lr{y^\prime}^n = constant.
\]
\[
	\lr{n-1}\lr{y^\prime}^n = constant\cdot \e^{-y}.
\]
Let $constant = \lr{n-1}\cdot C_0^{\,n}$, where $C_0$ is an arbitrary constant.  Then,
\[
	\lr{n-1}\lr{y^\prime}^n = \lr{n-1}C_0^{\,n}\cdot\e^{-y},
\]
and so,
\[
	y^\prime = C_0\cdot\e^{-\lr{\dfrac{y}{n}}}.
\]
This differential equation can be solved as follows.

First rewrite the equation as
\[
	\deriv{y(x)}{x} = C_0\cdot\e^{-\lr{\dfrac{y(x)}{n}}}.
\]
Divide throughout  by $\exp\lr{-y(x)/n}$ to obtain
\[
	\e^{\lr{\dfrac{y(x)}{n}}}\cdot \deriv{y(x)}{x}=C_0.
\]
Integrate the above with respect to $x$
\[
	\Int{•}{•}{x} \,e^{\lr{\dfrac{y(x)}{n}}}\cdot \deriv{y(x)}{x} = \Int{•}{•}{x} C_0.
\]
Thus,
\[
	n\cdot e^{\lr{\dfrac{y(x)}{n}}} = C_0 x + C_1,\quad\textrm{where $C_1$ is an arbitrary constant.}
\]
Solving the above for $y(x)$
\[
	\ln\lr{n\cdot e^{\lr{\dfrac{y(x)}{n}}}} = \ln\lr{C_0 x + C_1},
\]
\[
	\ln\lr{n} + \ln\lr{\e^{\lr{\dfrac{y(x)}{n}}}} = \ln\lr{C_0 x + C_1},
\]
\[
	\dfrac{y(x)}{n} + \ln\lr{n} = \ln\lr{C_0 x + C_1},
\]
\[
	y(x) = n\cdot\ln\lr{C_0 x + C_1} -n\cdot\ln\lr{n}.
\]
Therefore,
\[
	y(x) = n\cdot\ln\lr{\dfrac{C_0 x + C_1}{n}}.
\]
Now, the boundary conditions $y(0)=1$ and $y(1) = A >1$ will allow the constants $C_0$ and $C_1$ to be found.

When $x=0$,\,\,$y=1$,
\begin{align*}
	{}& 1 =\,n\cdot\ln\lr{\dfrac{C_1}{n}},\\
	{}& \dfrac{1}{n} =\,\ln\lr{\dfrac{C_1}{n}},\\
	{}& \e^{\lr{\dfrac{1}{n}}} =\, \dfrac{C_1}{n},\\
	{}& C_1 =\, n\cdot \e^{\lr{\dfrac{1}{n}}},\quad \textrm{so}\\
	{}& y(x) =\, n\cdot\ln\lr{\dfrac{C_0 x + n\cdot\e^{\lr{\dfrac{1}{n}}}}{n}}.
\end{align*}
When $x=1,\, y=A$,
\begin{align*}
	{}& A =\, n\cdot\ln\lr{\dfrac{C_0 + n\cdot\e^{\lr{\dfrac{1}{n}}}}{n}},\\
	{}& \dfrac{A}{n} =\, \ln\lr{\dfrac{C_0 + n\cdot\e^{\lr{\dfrac{1}{n}}}}{n}},\\
	{}& \e^{\lr{\dfrac{A}{n}}} =\, \dfrac{C_0 + n\cdot\e^{\lr{\dfrac{1}{n}}}}{n},\\
	{}& n\cdot\e^{\lr{\dfrac{A}{n}}} =\,  C_0 + n\cdot\e^{\lr{\dfrac{1}{n}}},\quad \textrm{so}\\
	{}& C_0 =\,n\lr{e^{\lr{\dfrac{A}{n}}} - e^{\lr{\dfrac{1}{n}}}}.
\end{align*}
Let $C_0/n = c$, a constant, then
\[
	y(x) =\,n\cdot\ln\lr{c x + \e^{\lr{\dfrac{1}{n}}}},
\]
and
\[
	c = \lr{e^{\lr{\dfrac{A}{n}}} - e^{\lr{\dfrac{1}{n}}}}.
\]
as required.<file_sep>/q2a.tex
% !TeX root = ./TMA02.tex
\def\F{ y_1^{\prime2}  + 2y_2^{\prime2}+\left(2y_1+y_2\right)^2}%
Given
\[
	S\left[y_1,y_2\right] = \Int{}{}{x}\left( \F \right),
\]
the first coupled \el is
\[
	\ELE{F}{x}{y_{1}},
\]
where
\[
	F = \F.
\]
So,
\begin{align*}
	\pderiv{F}{y_1^\prime} =& 2y_1^\prime,\quad \deriv{\left(2y_1^\prime\right)}{x} = 2y_1^\dprime,\quad\textrm{and}\\
	\pderiv{F}{y_1}=&2\left(2y_1+y_2\right)2 = 4\left(2y_1+y_2\right).
\end{align*}
Thus, the \el for the first coupled equation is
\begin{equation}
	\label{eq:2.1}
	2y_1^\dprime - 4\left(2y_1+y_2\right) = 0.
\end{equation}
The second coupled \el is
\[
	\ELE{F}{x}{y_{2}}.
\]
So,
\begin{align*}
	\pderiv{F}{y_2^\prime} =& 4y_2^\prime,\quad \deriv{\left(4y_2^\prime\right)}{x} = 4y_2^\dprime,\quad\textrm{and}\\
	\pderiv{F}{y_2}=&2\left(2y_1+y_2\right).
\end{align*}
Thus, the \el for the second coupled equation is
\begin{equation}
	\label{eq:2.2}
	4y_2^\dprime - 2\left(2y_1+y_2\right) = 0.
\end{equation}<file_sep>/q1a.tex
% !TeX root = ./TMA02.tex
Given,
\[
	S[y] = \int_a^b \dd x\left(y^2\sinh x -\frac{2y^{\prime 2}}{\sinh x}\right),\quad y(a) = A,\quad y(b) = B,\quad 0< a < b,
\]
then
\[
	\textrm{Let } F = y^2\sinh x -\frac{2y^{\prime 2}}{\sinh x}.
\]
The following derivatives are required to determine the \el\marginnote{Making use of the quotient rule here.}
\begin{equation*}
\begin{split}
	\pderiv{F}{y^\prime} =& -\frac{4y^\prime}{\sinh x}.\\\\
	\deriv{}{x}\left(\pderiv{F}{y^\prime}\right) =& \deriv{}{x}\left( -\frac{4y^\prime}{\sinh x}\right),\\
	=& \frac{\sinh x\left(-4y^\dprime\right)-\left(-4y^\prime\right)\cosh x }{\sinh^2x},\\
	=& \frac{4}{\sinh x}\left(y^\prime\frac{\cosh x}{\sinh x}-y^\dprime\right),\\\\
	\textrm{and}\quad\quad{} \pderiv{F}{y}=& 2y\sinh x.
\end{split}
\end{equation*}
The \el is given by
\[
	\EL,
\]
and substituting into this equation the expressions for the derivatives obtained above gives the \el associated with the functional $S[y]$,
\[
	\frac{4}{\sinh x}\left(y^\prime\frac{\cosh x}{\sinh x}-y^\dprime\right) - 2y\sinh x = 0,
\]
which can be rearranged into the following,
\begin{gather}
	2\sinh(x)\cdot y^\dprime - 2\cosh(x)\cdot y^\prime + \sinh^3(x)\cdot y = 0, \\
	y(a) = A,\, y(b) = B,\, 0< a < b.\nonumber
\end{gather}<file_sep>/q1.tex
% !TeX root = ./TMA02.tex
\begin{question}
\qpart %(a)
\input{q1a}
\qpart %(b)
\input{q1b}
\qpart %(c)
\input{q1c}
\qpart %(d)
\input{q1d}
\end{question}<file_sep>/q1d.tex
% !TeX root = ./TMA02.tex
\def\osx[#1]{{\L\frac{1}{\sqrt{2}}\cosh {#1}\R}}%
\def\os2{\frac{1}{\sqrt{2}}}%
Substituting into \eqref{eq:1.2} for $u=\cosh x$ gives,
\begin{equation}
\label{eq:1.4}
	y(x) = c_1\cos\osx[x] + c_2\sin\osx[x],
\end{equation}
Now, when $x=1$, $y=0$ and when $x=2$, $y=2$. Substituting  these boundary conditions into the above expression for $y$ \eqref{eq:1.4} gives the following pair of simultaneous equations,
\begin{align*}
	0 =& c_1\cos\osx[1] + c_2\sin\osx[1],\quad\textrm{and}\\
	2 =& c_1\cos\osx[2] + c_2\sin\osx[2].
\end{align*}
Solving for the constants $c_1$ and $c_2$ gives,
\begin{align*}
	c_1 =&\frac{
				-2\sin\osx[1]
		      }
		      {
		      	\sin\osx[2]\cos\osx[1]-\sin\osx[1]\cos\osx[2]
		      },\\
	c_2 =&\frac{
				2\cos\osx[1]
		      }
		      {
		      	\sin\osx[2]\cos\osx[1]-\sin\osx[1]\cos\osx[2]
		      }.
\end{align*}
Making use of the identity $\sin\L\alpha-\beta\R = \sin\alpha\cos\beta -\cos\alpha\sin\beta$, then the above pair of equations can be simplified to
\begin{align*}
	c_1 =&\frac{
				-2\sin\osx[1]
		      }
		      {
		      	\sin \L \os2 \cosh 2 - \os2 \cosh 1\R
		      },\\
	c_2 =&\frac{
				2\cos\osx[1]
		      }
		      {
		      	\sin \L \os2 \cosh 2 - \os2 \cosh 1\R
		      }.
\end{align*}
Thus, substituting into \eqref{eq:1.4} for $c_1$ and $c_2$ gives,
\[
	y(x) = \frac{
				-2\sin\osx[1]\cos\osx[x] + 2\cos\osx[1]\sin\osx[x]
			}
			{
				\sin \L \os2 \cosh 2 - \os2 \cosh 1\R
			}.
\]
Simplifying the above using the same trig identity as before gives,
\[
	y(x) = \frac{
				2\sin\L\os2\L\cosh x - \cosh 1\R \R
			}
			{
				\sin \L \os2 \cosh 2 - \os2 \cosh 1\R
			}
\]
as required.<file_sep>/q5a.tex
% !TeX root = ./TMA02.tex
\def\yp{y^{\prime}}
\vspace{-6mm}
\begin{equation*}
	F=f(x)\,\,\sqrt[•]{1+y^{\prime2}} = f(x)\,\,\lr{1 + y^{\prime2}}^\half.
\end{equation*}
The \el is,
\[
	\ELE{F}{x}{y},
\]
\[
	\deriv{}{x}\lr{\pderiv{F}{y^\prime}} = 0,\quad\textrm{so, }\quad\pderiv{F}{y^\prime} = \beta,\quad \textrm{where } \beta \textrm{ is a constant.}
\]
\[
	\pderiv{F}{y^\prime} =\half\, f(x) \lr{ 1+y^{\prime2}}^{-\half}\,2y^\prime = \beta.
\]
\begin{align*}
	f(x) \,   \frac{y^\prime}{\lr{1 + y^{\prime2}}^\half} =&\beta,\\
	f(x)^2 \, \frac{y^{\prime2}}{\lr{1 + y^{\prime2}}} =& \beta^2,\\
	f(x)^2 \,y^{\prime2} = \beta^2\lr{1 + y^{\prime2}} =& \beta^2 + \beta y^{\prime2},\\
	f(x)^2 \,y^{\prime2} - \beta^2 - \beta^2 y^{\prime2} =& 0,\\
	y^{\prime2} \,\lr{f(x)^2 - \beta^2 } =& \beta^2,\\
	y^{\prime2}  = \frac{\beta^2}{\lr{f(x)^2 - \beta^2 }}.\\
	\textrm{Thus,}\quad y^{\prime}  = \frac{\beta}{\sqrt{f(x)^2 - \beta^2 }}.
\end{align*}
Integrating the last expression gives,
\[
	y(x) = C + \beta \Int{a}{x}{w}\frac{1}{\sqrt{f(w)^2 - \beta^2 }},\quad\textrm{where $C$ is a constant.}
\]
Now, $y(a) = A$, and applying this to the above expression for $y(x)$ gives,
\[
	A = C + \cancelto{0}{\beta\int_a^a\dd w\, \frac{1}{\sqrt{f(w)^2 -\beta^2}}},\qquad\textrm{therefore, } C=A.
\]
\[
	\textrm{Hence,}\qquad y(x) = A + \beta \Int{a}{x}{w}\frac{1}{\sqrt{f(w)^2 - \beta^2 }},\qquad\textrm{as required.}
\]
Also, $y(b) = B$ so,
\[
	B = A + \beta\int_a^b\dd w\, \frac{1}{\sqrt{f(w)^2 -\beta^2}}.
\]
Hence, the constant $\beta$ satisfies,
\[
	B - A = \beta \int_a^b\dd w\, \frac{1}{\sqrt{f(w)^2 -\beta^2}}.
\]<file_sep>/q5c.tex
% !TeX root = ./TMA02.tex
\def\hp{h^\prime}%
If $y(x)$ is the stationary path $\lr{\yp(x)\neq0\textrm{ and } f(x)\neq 0}$ the value of the functional along another admissible path $x+h$ is
\[
	S[y+h] = \int_a^b\dd x\, f(x)\sqrt{1+\lr{y^\prime + h^\prime}^2}.
\]
Using the result
\[
	\sqrt{1+(z+u)^2} - \sqrt{1+z^2} \geq \frac{zu}{\sqrt{1+z^2}},
\]
for the case where $z=\yp$ and $u=\hp$, it is seen that
\[
	\sqrt{1+(\yp+\hp)^2} - \sqrt{1+y^{\prime2}} \geq \frac{\yp\hp}{\sqrt{1+y^{\prime2}}}.
\]
\[
	S[y+h] - S[y] = \int_a^b\dd x\,\lrc{f(x)\sqrt{1+\lr{y^\prime + h^\prime}^2} - f(x)\sqrt{1+y^{\prime2}}},
\]
\begin{align*}
	S[y+h] - S[y] =& \int_a^b\dd x\,f(x)\lrc{\sqrt{1+\lr{y^\prime + h^\prime}^2} - \sqrt{1+y^{\prime2}}},\\
	\geq& \int_a^b\dd x\,f(x)\frac{\yp}{\sqrt{1+y^{\prime2}}}\hp,\quad f(x) > 0.
\end{align*}
\marginnote{Inequality sign passes through integral here as $f(x)>0$.}[-1.5cm]%
The \el for the functional gave
\[
	f(x)\frac{\yp}{\sqrt{1+y^{\prime2}}}=\beta,
\]
where $\beta$ is a constant.  Hence,
\[
	S[y+h] - S[y] \geq \beta\int_a^b\dd x\,\hp = 0
\]
as $h(a)=0$ and $h(b)=0$ since $y(a)=A$ and $y(b) = B$.

As $\yp(x) \neq	0$ and $f(x) \neq 0$ the stationary path found in part~(a) gives a global minimum of the functional $S[y]$, since $S[y] \leq S[y+h]$ for \textbf{all} $h$.\par\noindent\rule{\textwidth}{0.4pt}<file_sep>/q3b.tex
% !TeX root = ./TMA02.tex
In order to show that $S[y]$ is invariant under the scale transformation $\bar{x}=\alpha x$, $\bar{y} = \beta y$, where $\alpha$ and $\beta$ are constants satisfying $\alpha^2\beta = 1$, consider the following.
\[
	\bar{x}=\alpha x,\quad \bar{y}=\beta y,\quad \alpha^2\beta = 1.
\]
\begin{align*}
	\Sv{y} =& \Int{a}{b}{x} \func.\\
	\Sv{\bar{y}} =& \Int{\bar{a}}{\bar{b}}{\bar{x}} \bar{x}^5\lr{\lr{\deriv{\bar{y}}{\bar{x}}}^2 - \2o3 \bar{y}^3},\\
	\Sv{\bar{y}} =& \Int{\bar{a}}{\bar{b}}{\bar{x}} \lr{\bar{x}^5\lr{\deriv{\bar{y}}{\bar{x}}}^2 - \2o3\bar{x}^5 \bar{y}^3}.
\end{align*}
Now, changing the variables, $\bar{x}=\alpha x$, $\bar{y}=\beta y$ and noting that
\[
	\deriv{\bar{y}}{\bar{x}} = \deriv{\bar{y}}{y}\cdot \deriv{y}{x}\cdot \deriv{x}{\bar{x}},
\]
\begin{align*}
	\Sv{\bar{y}} =& \int_a^b\alpha\dd x\lr{\alpha^5x^5\lr{\frac{\beta}{\alpha}\deriv{y}{x}}^2 - \2o3\alpha^5x^5\beta^3y^3},\\
	\Sv{\bar{y}}=& \int_a^b\alpha\dd x\lr{\alpha^5\frac{\beta^2}{\alpha^2}x^5\lr{\deriv{y}{x}}^2 - \2o3\alpha^5\beta^3x^5y^3},\\
	\Sv{\bar{y}}=& \Int{a}{b}{x}\lr{\alpha^4\beta^2x^5\lr{\deriv{y}{x}}^2 - \2o3\alpha^6\beta^3x^5y^3},\\
	\Sv{\bar{y}}=&\alpha^4\beta^2\Int{a}{b}{x}\lr{x^5\lr{\deriv{y}{x}}^2- \2o3\alpha^2\beta x^5y^3},\\
	\Sv{\bar{y}}=&\alpha^4\beta^2\Int{a}{b}{x}x^5 \lr{y^{\prime2} - \2o3 \alpha^2\beta y^3}.
\end{align*}
As $\alpha^2\beta=1$, then the last expression for $\Sv{\bar{y}}$ can be simplified to
\[
	\Sv{\bar{y}} = \Int{a}{b}{x}x^5 \lr{y^{\prime2} - \2o3 y^3}.
\]
Hence, $\Sv{\bar{y}} = \Sv{y}$ and thus it has been shown that $S[y]$ is invariant under the scale transformation outlined above.<file_sep>/q2c.tex
% !TeX root = ./TMA02.tex
\[
	S\left[z_1,z_2\right] = \Int{}{}{x} \underbrace{\frac{1}{9}z_1^{\prime2}}_{=F_1} + \Int{}{}{x}\underbrace{\left(\frac{2}{9}z_2^{\prime2} + z_2^2\right)}_{=F_2}.
\]
The \el for $F_2$ is determined as follows.
\[
	\pderiv{F_2}{z_2^\prime} =\frac{4}{9}z_2^\prime,\quad\deriv{}{x}\left(\frac{4}{9}z_2^\prime\right)=\frac{4}{9}z_2^\dprime,\quad \pderiv{F_2}{z_2} = 2z_2.
\]
Therefore, the \el is given by
\[
	\ELE{F_2}{x}{z_2}.
\]
Substituting into the above \el gives,
\[
	\frac{4}{9}z_2^\dprime -2z_2 = 0.
\]
This differential equation has solution
\begin{equation}
\label{eq:2.13}
	z_2 = c_1\e^{\frac{3}{\sqrt{2}}x} + c_2\e^{-\frac{3}{\sqrt{2}}x},
\end{equation}
where $c_1$ and $c_2$ are arbitrary constants.

The \el for $F_1$ is determined as follows.
\[
	\pderiv{F_1}{z_1^\prime} =\frac{2}{9}z_1^\prime,\quad\deriv{}{x}\left(\frac{2}{9}z_1^\prime\right)=\frac{2}{9}z_1^\dprime,\quad \pderiv{F_1}{z_1} = 0.
\]
Therefore, the \el is given by
\[
	\ELE{F_1}{x}{z_1}.
\]
Substituting into the above \el gives,
\[
	\frac{2}{9}z_1^\dprime = 0.
\]
This differential equation has solution
\begin{equation}
\label{eq:2.14}
	z_1 = c_3x + c_4,
\end{equation}
where $c_3$ and $c_4$ are arbitrary constants.

From part~(b) $a=-4$, thus,
\[
	z_1 = y_1 - 4y_2\quad \textrm{and so}\quad c_3x + c_4 = y_1 - 4y_2.
\]
Rearranging the above in terms of $y_1$ gives,
\[
	y_1 = c_3x+c_4+4y_2.
\]
\[
	z_2 =2y_1 + y_2\quad\textrm{and so}\quad c_1\e^{\frac{3}{\sqrt{2}}x} + c_2\e^{-\frac{3}{\sqrt{2}}x} = 2y_1 + y_2.
\]
Rearranging the above in terms of $y_1$ gives
\[
	y_1 = \half c_1\e^{\frac{3}{\sqrt{2}}x} + \half c_2\e^{-\frac{3}{\sqrt{2}}x} - \half y_2.
\]
Equating the expressions for $y_1$
\[
	c_3x + c_4 + 4y_2 = \half c_1\e^{\frac{3}{\sqrt{2}}x} + \half c_2\e^{-\frac{3}{\sqrt{2}}x} - \half y_2,
\]
and rearranging the above in terms of $y_2$
\begin{align*}
	{}&\half c_1\e^{\frac{3}{\sqrt{2}}x} + \half c_2\e^{-\frac{3}{\sqrt{2}}x} - c_3x - c_4 = \half y_2 + 4y_2 = \frac{9}{2}y_2,\\
	{}&y_2 = \frac{2}{9}\left[\half c_1\e^{\frac{3}{\sqrt{2}}x} + \half c_2\e^{-\frac{3}{\sqrt{2}}x} - c_3x - c_4\right].
\end{align*}
From above,
\[
	c_3x + c_4-y_1 = -4y_2\quad\textrm{and}\quad c_1\e^{\frac{3}{\sqrt{2}}x} + c_2\e^{-\frac{3}{\sqrt{2}}x} - 2y_1 =y_2.
\]
Multiplying the expression immediately above for $y_2$ by $-4$ gives,
\[
	-4c_1\e^{\frac{3}{\sqrt{2}}x} -4c_2\e^{-\frac{3}{\sqrt{2}}x} + 8y_1 =-4y_2.
\]
Thus,
\[
	c_3x + c_4 - y_1 = -4c_1\e^{\frac{3}{\sqrt{2}}x} -4c_2\e^{-\frac{3}{\sqrt{2}}x} + 8y_1,
\]
and rearranging the above in terms of $y_1$ gives,
\[
	c_3x + c_4 + 4c_1\e^{\frac{3}{\sqrt{2}}x} + 4c_2\e^{-\frac{3}{\sqrt{2}}x} = 8y_1 + y_1 = 9y_1,
\]
\[
	y_1 = \frac{1}{9}\left[c_3x + c_4 + 4c_1\e^{\frac{3}{\sqrt{2}}x} + 4c_2\e^{-\frac{3}{\sqrt{2}}x}\right].
\]<file_sep>/q3d.tex
% !TeX root = ./TMA02.tex
\def\y1p{y_1^{\prime}}
\[
	y_1 = Ax^{-2}\quad\textrm{and}\quad y_2=\frac{B}{\lr{x^2 +\frac{B}{24}}^2}.
\]
The first-integral is
\[
	4 x^5yy^\prime + x^6\lr{y^{\prime2}+\2o3 y^3} = c.
\]
\marginnote{A and B are constants.}[0.6cm]
\[
	\y1p = -2Ax^{-3},\quad y_1^{\prime2} = \lr{-2Ax^{-3}}^2 = 4A^2x^{-6},\quad y_1^3 = A^3x^{-6}.
\]
Substituting these expressions into the first-integral gives,\marginnote{Recall, $c$ is a constant.}[1.2cm]
\begin{align*}
	4x^5Ax^{-2}\lr{-2Ax^{-3}} + x^6\lr{4A^2x^{-6} + \2o3 A^3 x^{-6}} = c,\\
	-8A^2 + 4A^2 + \2o3 A^3 = c,\\
	\frac{-24A^2 + 12A^2 + 2A^3}{3} = c,\\
	\underbrace{\frac{-12A^2+2A^3}{3}}_\textrm{and this is a constant so equation is satisfied.} = c.
\end{align*}
\[
	y_2 = \frac{B}{\lr{x^2 + \frac{B}{24}}^2},\quad y_2 = B \lr{x^2 + \frac{B}{24}}^{-2},\quad y_2^\prime = -\frac{4Bx}{\lr{x^2 + \frac{B}{24}}^3}.
\]
Substituting these expressions into the first-integral gives,
\begin{align*}
	c=& 4x^5\frac{B}{\lr{x^2 + \frac{B}{24}}^2}\frac{\lr{-4Bx}}{\lr{x^2 + \frac{B}{24}}^3} + x^6\lr{\frac{16B^2x^2}{\lr{x^2 + \frac{B}{24}}^6} + \2o3\frac{B^3}{\lr{x^2 + \frac{B}{24}}^6}},\\
	c=& -\frac{16x^6B^2}{\lr{x^2 + \frac{B}{24}}^5} + x^6\lr{\frac{48B^2x^2 + 2B^3}{3\lr{x^2 + \frac{B}{24}}^6}},\\
	c=& -\frac{16x^6B^2}{\lr{x^2 + \frac{B}{24}}^5} + \frac{2x^6B^2}{\lr{x^2 + \frac{B}{24}}^5}\lr{\frac{24x^2 + B}{3\lr{x^2 + \frac{B}{24}}}},\\
	c=& -\frac{16x^6B^2}{\lr{x^2 + \frac{B}{24}}^5} + \frac{2x^6B^2}{\lr{x^2 + \frac{B}{24}}^5}\lr{\frac{\cancelto{1}{\lr{24x^2 + B}}}{\cancelto{\frac{1}{8}}{\frac{3}{24}}\cancelto{1}{\lr{24x^2 + B}}\,\,\,}},\\
	c=& -\frac{16x^6B^2}{\lr{x^2 + \frac{B}{24}}^5}  + \frac{2x^6B^2}{\lr{x^2 + \frac{B}{24}}^5}\lr{8},\\
	c=& -\frac{16x^6B^2}{\lr{x^2 + \frac{B}{24}}^5}  + \frac{16x^6B^2}{\lr{x^2 + \frac{B}{24}}^5},\\
	c=& 0.
\end{align*}
Thus, $y_1$ and $y_2$ both give solutions to the first-integral for any constant values $A$ or $B$.

The \el is given by,
\[
	\ELE{F}{x}{y},
\]
and
\[
	F = x^5\lr{y^{\prime2} - \2o3 y^3}.
\]
\[
	\pderiv{F}{y^\prime} = 2x^5y^\prime,\quad \deriv{}{x}\lr{2x^5y^\prime} = 2x^5y^{\dprime} + y^\prime 10x^4.
\]
\[
	\pderiv{F}{y} = \pderiv{}{y}\lr{x^5y^{\prime2} - \2o3 x^5 y^3} = -2x^5y^2.
\]
The \el is
\[
	2x^5y^\dprime + 10x^4y^\prime + 2x^5 y^2 = 0,
\]
which, after dividing through out by $2x^5$ gives,
\[
	y^\dprime + \frac{5}{x} y^\prime + y^2 = 0,\quad \textrm{as determined previously in part a above.}
\]
Now,
\[
	y=Ax^{-2},\quad y^\prime = -2Ax^{-3},\quad y^\dprime = 6Ax^{-4},
\]
and so,
\begin{align*}
	y^\dprime + \frac{5}{x} y^\prime + y^2 =& 6Ax^{-4} + \frac{5}{x}\lr{-2Ax^{-3}} + A^2x^{-4},\\
	=& 6Ax^{-4} - 10Ax^{-4} + A^2x^{-4}.\\
	=& -4Ax^{-4} + A^2x^{-4},\\
	=& \lr{A-4}Ax^{-4} = 0\quad \textrm{for all } A.
\end{align*}
Therefore, $A=0$ or $A=4$ satisfies the \el, so the value of the constant $A$ is not arbitrary.
\begin{align*}
	y =& \frac{B}{\lr{x^2 + \frac{B}{24}}^2}.\\
	y^\prime =& \frac{-2B2x}{\lr{x^2 + \frac{B}{24}}^3} = \frac{-4Bx}{\lr{x^2 + \frac{B}{24}}^3}.\\
	y^\dprime =& \frac{24Bx^2}{\lr{x^2 + \frac{B}{24}}^4} - \frac{4B}{\lr{x^2 + \frac{B}{24}}^3}.
\end{align*}
The \el is
\[
	y^\dprime + \frac{5}{x}y^\prime + y^2 = 0.
\]
Substituting into the \el for the expressions immediately above gives,
\begin{align*}
	{}&y^\dprime + \frac{5}{2}y^\prime + y^2 = \frac{24Bx^2}{\lr{x^2 + \frac{B}{24}}^4} - \frac{4B}{\lr{x^2 + \frac{B}{24}}^3}
	- \frac{5}{\cancelto{1}{x}}\frac{4B\cancelto{1}{x}}{\lr{x^2 + \frac{B}{24}}^3} + \frac{B^2}{\lr{x^2 + \frac{B}{24}}^4},\\
	{}&= \lr{x^2 + \frac{B}{24}}^{-4}\lr{24Bx^2 - 4B\lr{x^2+\frac{B}{24}}-20B\lr{x^2+\frac{B}{24}} + B^2},\\
	{}&= \lr{x^2 + \frac{B}{24}}^{-4}\lr{\cancel{24Bx^2} - \cancel{4Bx^2} - \frac{B^2}{6} - \cancel{20Bx^2} - \frac{\cancelto{5}{20}}{\cancelto{6}{24}}\,\,\,B^2 + B^2}\\
	{}&= \lr{x^2 + \frac{B}{24}}^{-4}\lr{-\frac{B^2}{6} - \frac{5}{6}B^2 + \frac{6}{6}B^2},\\
	{}&= \frac{1}{6}\lr{x^2 + \frac{B}{24}}^{-4}\lr{-6B^2 + 6B^2},\\
	{}&\textrm{so,}\quad y^\dprime + \frac{5}{2}y^\prime + y^2 = 0.
\end{align*}
Thus, the \el equation is satisfied regardless of the value of the constant $B$. Consequently, $B$ is an arbitrary constant.<file_sep>/q5.tex
% !TeX root = ./TMA02.tex
\begin{question}
\qpart %(a)
\input{q5a}
\qpart %(b)
\input{q5b}
\qpart %(c)
\input{q5c}
\end{question}

repo_language: TeX


text:
<file_sep>
import 'package:flutter/material.dart';

/**
 * 紫色区域是字体的行高 即参数height 其效果值是 fontSize 的倍数
 * 当 height 为空时，行高默认是使用字体的量度
 * 当 height 不是空时，行高为 height * fontSize 的大小
 *
 * StrutStyle
 *
 * leading 默认为 null ，同时它的效果也是 fontSize 的倍数，并且分布是上下均分
 */

class TextDemoPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      body: Container(
        color: Colors.blue,
        alignment: Alignment.center,
        child: Container(
          height: 200,
          color: Colors.yellow,
          alignment: Alignment.center,
          child: new Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Container(
                color: Colors.purple,
                child: new Text(
                  "Hg",
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    textBaseline: TextBaseline.ideographic,
                    fontSize: 100,
                    height: 2
                  ),
                  strutStyle: StrutStyle(
                    forceStrutHeight: true,
                    fontSize: 100,
                    height: 1,
                    leading: 1
                  ),
                ),
              ),
              Container(
                height: 100,
                width: 100,
                color: Colors.red,
              )
            ],
          ),
        ),
      ),
    );
  }
}<file_sep>import 'package:flutter/material.dart';
import 'package:hello_world/common/bgListView.dart';

class LayoutListPage extends StatefulWidget {

  @override
  State<StatefulWidget> createState() => _LayoutListPageState();
}

class _LayoutListPageState extends State<LayoutListPage> {

  final List<String> entries = <String>[
    'Center Layout',
    'Padding Layout',
    'Align Layout'
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Layout")),
      body: BGListView(
        listData: entries,
        itemBuilder: (BuildContext context, int index) {
          return ListTile(
            leading: Icon(Icons.book), // 左边Icon
            title: Text('Entry ${entries[index]}'), // 主标题
            trailing: Icon(Icons.arrow_right), // 右边Icon
          );
        },
        didClickItem: didClickItem,
      ),
    );
  }

  void didClickItem(int index) {
    switch (index) {
      case 0:
        // 居中布局
        Navigator.pushNamed(context, 'CenterLayoutDemo');
        break;
      case 1:
        // Padding布局
        Navigator.pushNamed(context, 'PaddingLayoutPage');
        break;
      case 2:
        // 对齐布局
        Navigator.pushNamed(context, 'AlignLayoutDemo');
        break;
    }
  }
}
<file_sep>import 'package:flutter/material.dart';
import 'package:hello_world/flipCard/bgFlipCard.dart';

class MiniGameCard extends StatelessWidget {

  final String item;
  final FlipDirection direction;  // 旋转方向
  final BoxDecoration? decoration; // 背景颜色
  final bool enabledFlip; // 是否支持旋转

  const MiniGameCard({
    Key? key,
    this.item = '',
    this.decoration,
    this.direction = FlipDirection.Horizontal,
    this.enabledFlip = false,
  }): super(key: key);

  @override
  Widget build(BuildContext context) {
    if (enabledFlip) {
      return buildBGFlipCard();
    } else {
      return buildBGCard();
    }
  }

  Widget buildBGCard() {
    return Container(
      key: Key(item.toString()),
      width: 100,
      height: 100,
      margin: EdgeInsets.symmetric(horizontal: 10),
      decoration: decoration,
      child: Center(
        child: Text(
          item.toString(),
          textAlign: TextAlign.center,
          style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold, color: Colors.white),
        )
      )
    );
  }

  Widget buildBGFlipCard() {
    return BGFlipCard(
      direction: direction,
      front: Container(
        key: Key(item.toString()),
        width: 100,
        height: 100,
        margin: EdgeInsets.symmetric(horizontal: 10),
        decoration: decoration,
      ),
      back: Container(
        key: Key(item.toString()),
        width: 100,
        height: 100,
        margin: EdgeInsets.symmetric(horizontal: 10),
        decoration: decoration,
        child: Center(
          child: Text(
            item.toString(),
            textAlign: TextAlign.center,
            style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold, color: Colors.white),
          )
        )
      ),
    );
  }
}
<file_sep>import 'package:flutter/material.dart';

// 参考：https://blog.csdn.net/weixin_33812433/article/details/91418996

class BGDialog {
  static void showGlobalDialog(context) {
    showDialog(
      context: context,
      barrierDismissible: false, // 半透明背景
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text("标题"),
          content: Text("内容"),
          actions: <Widget>[
            TextButton(
              onPressed: () => {
                // print('取消');
                Navigator.pop(context)
              },
              child: Text('取消')
            ),
            TextButton(
              onPressed: () => {
                print('确定')
              },
              child: Text('确定')
            )
          ],
        );
      }
    );
  }
}<file_sep>import 'package:flutter/material.dart';

class LetterList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    String str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    return Scrollbar(
      child: SingleChildScrollView(
        child: Center(
          child: Column(
            children: str.split("").map((e) => Text(e)).toList(),
          ),
        ),
      ),
    );
  }
}
<file_sep>import 'package:flutter/material.dart';
import 'package:hello_world/common/bgListView.dart';

//   底部多项选择弹窗
//   maxHeight: 内容区域的最大高度默认为 constraints.maxHeight * 9.0 / 16.0, 可通过isScrollControlled以及itemBuilder来自定义
//   shape: 定义边框形状, 如定义为 => 左上右上均为圆角
//   RoundedRectangleBorder(
//     borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)),
//     side: BorderSide(
//       width: 2,
//       color: Colors.blue,
//       style: BorderStyle.solid
//     )
//   )

typedef BGOnClickSheetFunction = void Function(int);
typedef BGSheetItemBuilder = Widget Function(BuildContext, int);

class BGBottomSheet {
  static showGlobalBottomSheet({
    required BuildContext context,
    required List<dynamic> listData,
    required BGSheetItemBuilder itemBuilder,
    bool enableDrag = true, // 是否支持拖拽消失
    bool isDismissible = true, // 是否支持点击空白消失
    Color? barrierColor, // 蒙层背景颜色
    Color? backgroundColor, // 内容区域背景颜色
    double? elevation, // 下影值
    ShapeBorder? shape,
    BGOnClickSheetFunction? onClickSheet,
  }) {
    showModalBottomSheet(
      context: context,
      enableDrag: enableDrag,
      barrierColor: barrierColor,
      elevation: elevation,
      backgroundColor: backgroundColor,
      shape: shape,
      isDismissible: isDismissible,
      builder: (BuildContext context) {
        return Padding(
          child: BGListView(
            listData: listData,
            didClickItem: onClickSheet,
            itemBuilder: itemBuilder
          ),
          padding: EdgeInsets.symmetric(vertical: 20),
        );
      }
    );
  }
}
<file_sep>/**
 * 待实现功能
 * 1、下拉刷新、上拉加载更多
 * 2、空白页面
 * 参考：https://github.com/damengzai/flutter-test
 */

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

typedef BGListViewFunction = Future Function();

class BGListView extends StatefulWidget {
  final List listData; // 列表数据
  final Widget Function(BuildContext, int) itemBuilder; // 单个样式
  final void Function(int)? didClickItem; // 点击某个样式
  final Axis scrollDirection; // 滚动方向
  final BGListViewFunction? onLoad;
  final BGListViewFunction? onRefresh;
  final bool enablePulldown;
  final bool enablePullup;

  // 构造函数
  const BGListView(
      {required this.listData,
      required this.itemBuilder,
      this.onLoad,
      this.onRefresh,
      this.didClickItem,
      this.scrollDirection = Axis.vertical,
      this.enablePullup = false,
      this.enablePulldown = false})
      : super();

  @override
  State<StatefulWidget> createState() {
    return _BGListViewState();
  }
}

class _BGListViewState extends State<BGListView> {
  RefreshController _refreshController =
      RefreshController(initialRefresh: false);

  @override
  Widget build(BuildContext context) {
    return SmartRefresher(
      enablePullDown: widget.enablePulldown,
      enablePullUp: widget.enablePullup,
      header: WaterDropHeader(),
      footer: CustomFooter(builder: (BuildContext context, LoadStatus? mode) {
        Widget body;
        if (mode == LoadStatus.idle) {
          body = Text("上拉加载");
        } else if (mode == LoadStatus.loading) {
          body = CupertinoActivityIndicator();
        } else if (mode == LoadStatus.failed) {
          body = Text("加载失败！点击重试!");
        } else if (mode == LoadStatus.canLoading) {
          body = Text("松手，加载更多!");
        } else {
          body = Text("没有更多数据了!");
        }
        return Container(
          height: 55.0,
          child: Center(child: body),
        );
      }),
      onRefresh: _onRefresh,
      onLoading: _onLoad,
      controller: _refreshController,
      child: ListView.separated(
        itemBuilder: (BuildContext context, int index) {
          return buildItem(context, index);
        },
        scrollDirection: widget.scrollDirection,
        separatorBuilder: (BuildContext context, int index) => const Divider(),
        itemCount: widget.listData.length,
      ),
    );
  }

  Widget buildItem(BuildContext context, int index) {
    return GestureDetector(
      child: widget.itemBuilder(context, index),
      onTap: () {
        if (widget.didClickItem != null) {
          widget.didClickItem!(index);
        }
      },
    );
  }

  void _onRefresh() async {
    if (widget.onRefresh != null) {
      await widget.onRefresh!();
      _refreshController.refreshCompleted();
    }
  }

  void _onLoad() async {
    if (widget.onLoad != null) {
      await widget.onLoad!();
      _refreshController.loadComplete();
    }
  }
}
<file_sep>import 'package:flutter/material.dart';
import 'package:hello_world/flipCard/bgFlipCard.dart';

class BGAnimationCard extends StatelessWidget {
  BGAnimationCard({this.child, this.animation, this.direction});

  final Widget? child;
  final Animation<double>? animation;
  final FlipDirection? direction;

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: animation!,
      builder: (BuildContext context, Widget? child) {
        var transform = Matrix4.identity();
        transform.setEntry(3, 2, 0.001);
        if (direction == FlipDirection.Vertical) {
          transform.rotateX(animation!.value);
        } else {
          transform.rotateY(animation!.value);
        }
        return Transform(
          transform: transform,
          alignment: Alignment.center,
          child: child,
        );
      },
      child: child,
    );
  }
}
<file_sep>import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

class HttpClient {
  static Dio _dio = Dio();

  static Future<T> _request<T>(String path,
      {String? method,
      Map<String, dynamic>? params,
      data,
      CancelToken? cancelToken}) async {
    try {
      Response response = await _dio.request(path,
          data: data,
          queryParameters: params,
          options: Options(
            method: method,
          ),
          cancelToken: cancelToken);
      return response.data;
    } on DioError catch (e) {
      // The request was made and the server responded with a status code
      // that falls out of the range of 2xx and is also not 304.
      LogUtil.v(_dioError(e), tag: '请求异常');
      EasyLoading.showInfo(_dioError(e));
      throw e;
    } catch (e) {
      throw e;
    }
  }

  // 处理 Dio 异常
  static String _dioError(DioError error) {
    switch (error.type) {
      case DioErrorType.connectTimeout:
        return "网络连接超时，请检查网络设置";
      case DioErrorType.receiveTimeout:
        return "服务器异常，请稍后重试！";
      case DioErrorType.sendTimeout:
        return "网络连接超时，请检查网络设置";
      case DioErrorType.response:
        return "服务器异常，请稍后重试！";
      case DioErrorType.cancel:
        return "请求已被取消，请重新请求";
      default:
        return "网络异常，请稍后重试！";
    }
  }

  static Future<T> get<T>(String path,
      {Map<String, dynamic>? params, CancelToken? cancelToken}) {
    return _request(path,
        method: 'get', params: params, cancelToken: cancelToken);
  }

  static Future<T> post<T>(String path,
      {Map<String, dynamic>? params, data, CancelToken? cancelToken}) {
    return _request(path,
        method: 'post', params: params, data: data, cancelToken: cancelToken);
  }
}
<file_sep>import 'package:flutter/material.dart';

/**
 * 如果它的尺寸受到约束且[widthFactor]和[heightFactor]为空，则此窗口小部件将尽可能大
 * 如果维度不受约束且相应的大小因子为null，则窗口小部件将匹配其在该维度中的子项大小（其实就是子view的宽高就是center容器的宽高）
 * 如果尺寸因子为非null，则此center容器的相应尺寸将是子view的尺寸和尺寸因子的乘积
 * 例如，如果widthFactor是2.0，那么此小部件的宽度将始终是其子宽度的两倍，并且将子view居中
 */

class CenterLayoutDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(title: Text("CenterLayoutDemo")),
      body: Container(
        child: Center(
          widthFactor: 2.0, // 宽度因子，Center组件的宽度等于子组件宽度 * 宽度因子
          heightFactor: 3.0, // 高度因子，Center组件的高度等于子组件高度 * 高度因子
          child: Container(
            width: 80,
            height: 80,
            decoration: BoxDecoration(
              color: Colors.red,
            )
          ),
        ),
        decoration: BoxDecoration(
            color: Colors.blue,
          )
      )
    );
  }
}
<file_sep>import 'package:flutter/material.dart';

typedef BGSliderFunction = void Function(double);

class BGSlider extends StatelessWidget {
  final double value; // 初始值
  final double minValue; // 最小值
  final double maxValue; // 最大值
  final Color? activeColor; // 滑动过的区域的颜色
  final Color? inactiveColor; // 未滑动过的区域的颜色
  final String? label; // divisions设置显示在节点上的label
  final int? divisions; // 分为几块，比如设置为5，Slider只能滑动到5个位置
  final BGSliderFunction? onChanged; // 变化时回调
  final BGSliderFunction? onChangeStart; // 滑动开始时回调一次
  final BGSliderFunction? onChangeEnd; // 滑动结束时回调一次

  const BGSlider({
    required this.value,
    this.minValue = 0.0,
    this.maxValue = 1.0,
    this.activeColor,
    this.inactiveColor,
    this.label,
    this.divisions,
    this.onChanged,
    this.onChangeEnd,
    this.onChangeStart
  }): super();

  @override
  Widget build(BuildContext context) {
    return Slider(
      value: value,
      min: minValue,
      max: maxValue,
      activeColor: activeColor,
      inactiveColor: inactiveColor,
      divisions: divisions,
      label: label,
      onChanged: onChanged,
      onChangeEnd: onChangeEnd,
      onChangeStart: onChangeStart,
    );
  }
}
<file_sep>import 'dart:math';

import 'package:flutter/material.dart';
import 'package:hello_world/flipCard/bgAnimationCard.dart';
import 'package:hello_world/flipCard/bgFlipCardController.dart';

typedef void BoolCallBack(bool isFront);

enum FlipDirection {
  Vertical, // 纵向
  Horizontal // 横向
}

class BGFlipCard extends StatefulWidget {

  final Widget front;
  final Widget back;

  final int speed;
  final FlipDirection direction;
  final VoidCallback? onFlip;
  final BoolCallBack? onFlipDone;
  final BGFlipCardController? controller;

  final bool flipOnTouch;
  final Alignment alignment;

  const BGFlipCard({
    Key? key,
    required this.front,
    required this.back,
    this.speed = 500,
    this.onFlip,
    this.onFlipDone,
    this.direction = FlipDirection.Horizontal,
    this.flipOnTouch = true,
    this.alignment = Alignment.center,
    this.controller,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return BGFlipCardState();
  }
}

class BGFlipCardState extends State<BGFlipCard> with SingleTickerProviderStateMixin {

  AnimationController? controller;
  Animation<double>? _frontRotation;
  Animation<double>? _backRotation;

  bool isFront = true;

  @override
  void initState() {
    super.initState();
    controller = AnimationController(
        duration: Duration(milliseconds: widget.speed),
        vsync: this);
    _frontRotation = TweenSequence(
      [
        TweenSequenceItem<double>(
          tween: Tween(begin: 0.0, end: pi / 2).chain(CurveTween(curve: Curves.easeIn)),
          weight: 50.0,
        ),
        TweenSequenceItem<double>(
          tween: ConstantTween<double>(pi / 2),
          weight: 50.0,
        ),
      ],
    ).animate(controller!);
    _backRotation = TweenSequence(
      [
        TweenSequenceItem<double>(
          tween: ConstantTween<double>(pi / 2),
          weight: 50.0,
        ),
        TweenSequenceItem<double>(
          tween: Tween(begin: -pi / 2, end: 0.0).chain(CurveTween(curve: Curves.easeOut)),
          weight: 50.0,
        ),
      ],
    ).animate(controller!);
    controller!.addStatusListener((status) {
      if (status == AnimationStatus.completed ||
          status == AnimationStatus.dismissed) {
        if (widget.onFlipDone != null) widget.onFlipDone!(isFront);
      }
    });

    widget.controller?.state = this;
  }

  @override
  Widget build(BuildContext context) {
    final child = Stack(
      alignment: widget.alignment,
      fit: StackFit.passthrough,
      children: <Widget>[
        _buildContent(front: true),
        _buildContent(front: false),
      ],
    );

    if (widget.flipOnTouch) {
      return GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: toggleCard,
        child: child,
      );
    }

    return child;
  }

  Widget _buildContent({required bool front}) {
    return IgnorePointer(
      ignoring: front ? !isFront : isFront,
      child: BGAnimationCard(
        animation: front ? _frontRotation : _backRotation,
        child: front ? widget.front : widget.back,
        direction: widget.direction,
      ),
    );
  }

  void toggleCard() {
    if (widget.onFlip != null) {
      widget.onFlip!();
    }

    controller!.duration = Duration(milliseconds: widget.speed);
    if (isFront) {
      controller!.forward();
    } else {
      controller!.reverse();
    }

    setState(() {
      isFront = !isFront;
    });
  }
}

<file_sep>import 'package:flutter/material.dart';

/**
 * Padding 即为填充组件，用于处理容器与其子元素之间的间距
 */

class AlignLayoutDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(title: Text("AlignLayoutDemo")),
      body: Stack(
        children: <Widget>[
          Align(
            alignment: FractionalOffset(0.5, 0.5), //
            child: Image.asset(
              'images/1.jpg',
              width: 120,
              height: 120,
            ),
          ),
          Align(
            alignment: FractionalOffset(0, 0),
            child: Image.asset(
              'images/2.jpg',
              width: 120,
              height: 120,
            ),
          ),
          Align(
            alignment: FractionalOffset.topRight,
            child: Image.asset(
              'images/3.jpg',
              width: 120,
              height: 120,
            ),
          ),
          Align(
            alignment: FractionalOffset.bottomLeft,
            child: Image.asset(
              'images/4.png',
              width: 120,
              height: 120,
            ),
          ),
          Align(
            alignment: FractionalOffset.bottomRight,
            child: Image.asset(
              'images/1.jpg',
              width: 120,
              height: 120,
            ),
          ),
        ],
      ),
    );
  }
}
<file_sep>/// Flutter code sample for ReorderableListView

import 'package:flutter/material.dart';
class TestReorderableListView extends StatefulWidget {

  final Axis scrollDirection;

  const TestReorderableListView({
    Key? key,
    this.scrollDirection = Axis.horizontal,
  }) : super(key: key);

  @override
  _TestReorderableListViewState createState() => _TestReorderableListViewState();
}

/// This is the private State class that goes with MyStatefulWidget.
class _TestReorderableListViewState extends State<TestReorderableListView> {
  final List<int> _items = List<int>.generate(20, (int index) => index);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('TestReorderableListView'),
      ),
      body: ReorderableListView(
        scrollDirection: widget.scrollDirection,
        padding: const EdgeInsets.symmetric(horizontal: 40),
        children: _items.map((item) => Dismissible(
          key: Key(item.toString()),
          child: Container(
            // height: 100,
            width: 100,
            margin: EdgeInsets.symmetric(horizontal: 50, vertical: 10),
            decoration: BoxDecoration(
              color: Colors.primaries[item % Colors.primaries.length],
              borderRadius: BorderRadius.circular(10)
            ),
          ),
          onDismissed: (direction) {
            setState(() {
              _items.removeAt(item);
            });

            // show a snackbar
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("$item dismissed")));
          },
          background: Container(color: Colors.red),
        )).toList(),
        onReorder: (int oldIndex, int newIndex) { // 拖动完成的回调 (旧的索引，新的索引)
          setState(() {
            if (oldIndex < newIndex) {
              newIndex -= 1;
            }
            final int item = _items.removeAt(oldIndex);
            _items.insert(newIndex, item);
          });
        },
      ),
    );
  }
}

<file_sep>import 'package:flutter/material.dart';
import 'package:hello_world/common/bgListView.dart';
import 'package:hello_world/common/bgSlider.dart';
import 'package:hello_world/views/school/cardItem.dart';

class MiniGame extends StatefulWidget {
  final Map? arguments;

  MiniGame({Key? key, this.arguments}) : super(key: key);

  @override
  _MiniGameState createState() => _MiniGameState();
}

class _MiniGameState extends State<MiniGame> {
  List<int> _items = List<int>.generate(2, (int index) => index);

  double _currentSliderValue = 20;

  @override
  Widget build(BuildContext context) {
    var arg = ModalRoute.of(context)?.settings.arguments;
    print("$arg");

    int cardwidth = 100;
    List shuffleItems = this.shuffleList(_items);

    return Scaffold(
        appBar: AppBar(title: Text('牌杀小游戏')),
        body: Center(
            child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
                width: 600,
                child: Stack(
                  children: [
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Padding(
                          padding: EdgeInsets.only(top: 20),
                          child: Text(
                            '预设两张牌的顺序，与对手进行竞猜，如果对应顺序的牌大于对方，则计1，如果总计数大于对方则赢，如果小于则输，相等为平',
                            style: TextStyle(fontSize: 18),
                            textAlign: TextAlign.center,
                          ),
                        ),
                        Padding(
                          padding: EdgeInsets.symmetric(vertical: 20),
                          child: Text(
                            '对方的顺序',
                            style: TextStyle(fontSize: 18),
                            textAlign: TextAlign.center,
                          ),
                        ),
                        SizedBox(
                            width:
                                ((cardwidth + 20) * _items.length).toDouble(),
                            height: 100,
                            child: BGListView(
                                scrollDirection: Axis.horizontal,
                                listData: shuffleItems,
                                itemBuilder: (BuildContext context, int index) {
                                  return MiniGameCard(
                                    enabledFlip: true,
                                    key: Key(index.toString()),
                                    item: shuffleItems[index].toString(),
                                    decoration: BoxDecoration(
                                        color: Colors.primaries[
                                            index % Colors.primaries.length],
                                        borderRadius:
                                            BorderRadius.circular(10)),
                                  );
                                })),
                        Padding(
                          padding: EdgeInsets.symmetric(vertical: 20),
                          child: Text(
                            '拖动进行顺序设定',
                            style: TextStyle(fontSize: 18),
                            textAlign: TextAlign.center,
                          ),
                        ),
                        Center(
                            child: SizedBox(
                                width: ((cardwidth + 20) * _items.length)
                                    .toDouble(),
                                height: 100,
                                child: ReorderableListView(
                                    scrollDirection: Axis.horizontal,
                                    children: _items
                                        .map((item) => MiniGameCard(
                                              key: Key(item.toString()),
                                              item: item.toString(),
                                              decoration: BoxDecoration(
                                                  color: Colors.primaries[item %
                                                      Colors.primaries.length],
                                                  borderRadius:
                                                      BorderRadius.circular(
                                                          10)),
                                            ))
                                        .toList(),
                                    onReorder: (int oldIndex, int newIndex) {
                                      // 拖动完成的回调 (旧的索引，新的索引)
                                      setState(() {
                                        if (oldIndex < newIndex) {
                                          newIndex -= 1;
                                        }
                                        final int item =
                                            _items.removeAt(oldIndex);
                                        _items.insert(newIndex, item);
                                      });
                                    }))),
                        Padding(
                          padding: EdgeInsets.symmetric(vertical: 20),
                          child: Text(
                            '设定竞猜金额(TRX)',
                            style: TextStyle(fontSize: 18),
                            textAlign: TextAlign.center,
                          ),
                        ),
                        BGSlider(
                            value: _currentSliderValue,
                            minValue: 1,
                            maxValue: 100,
                            divisions: 100,
                            label: _currentSliderValue.round().toString(),
                            activeColor: Colors.blue,
                            inactiveColor: Colors.red,
                            onChanged: (double value) {
                              setState(() {
                                _currentSliderValue = value;
                              });
                            }),
                      ],
                    ),
                  ],
                )),
            Padding(
                padding: EdgeInsets.only(bottom: 40),
                child: SizedBox(
                  height: 40,
                  width: 200,
                  child: ElevatedButton(
                    child: Text('参与小游戏'),
                    onPressed: () {
                      print('游戏结果');
                    },
                  ),
                ))
          ],
        )));
  }

  List<dynamic> shuffleList(List<dynamic> list) {
    List newList = [];
    newList.addAll(list);
    newList.shuffle();
    return newList;
  }
}
<file_sep>import 'package:flutter/material.dart';
import 'package:hello_world/common/bgBottomSheet.dart';
import 'package:hello_world/common/bgDialog.dart';
import 'package:hello_world/common/bgListView.dart';

import 'drawer.dart';

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _selectedIndex = 1;
  List<String> entries = <String>[
    '牌杀小游戏',
    'Layout',
    'ReorderableListView',
    'ListView',
    'Button',
    'Sliver',
    'Text',
    'Dialog',
    'BottomSheet',
    'ImagePicker',
    'Loading',
    'DateImagePicker',
    'Toast',
    'TextField',
  ];

  @override
  void initState() {
    super.initState();
    // 初始化状态
    print('initState');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // 导航栏
        title: Text(widget.title),
        centerTitle: false,
        actions: [IconButton(onPressed: () {}, icon: Icon(Icons.share))],
        leading: Builder(builder: (context) {
          return IconButton(
            icon: Icon(Icons.dashboard, color: Colors.white),
            onPressed: () {
              Scaffold.of(context).openDrawer();
            },
            tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
          );
        }),
      ),
      drawer: new LeftDrawer(),
      bottomNavigationBar: BottomNavigationBar(
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(label: 'School', icon: Icon(Icons.school)),
          BottomNavigationBarItem(
              label: 'Business', icon: Icon(Icons.business)),
          BottomNavigationBarItem(label: 'Me', icon: Icon(Icons.verified_user)),
        ],
        currentIndex: _selectedIndex,
        fixedColor: Colors.blue,
        onTap: _onItemTapped,
      ),
      body: Center(
          child: BGListView(
              listData: entries,
              enablePulldown: true,
              enablePullup: true,
              onRefresh: _onRefresh,
              onLoad: _onload,
              itemBuilder: (BuildContext context, int index) {
                print(index);
                return ListTile(
                  leading: Icon(Icons.book), // 左边Icon
                  title: Text('Entry ${entries[index]}'), // 主标题
                  trailing: Icon(Icons.arrow_right), // 右边Icon
                );
              },
              didClickItem: didClickItem)),
    );
  }

  Future _onRefresh() async {
    // monitor network fetch
    await Future.delayed(Duration(milliseconds: 1000));
  }

  Future _onload() async {
    await Future.delayed(Duration(milliseconds: 1000));
    // if failed,use loadFailed(),if no data return,use LoadNodata()
    entries.add((entries.length + 1).toString());
    if (mounted) setState(() {});
  }

  void didClickItem(int index) {
    switch (index) {
      case 0:
        // 牌杀小游戏
        Navigator.pushNamed(context, 'miniGame',
            arguments: {'title': "命令路由传递过来的title"});
        break;
      case 1:
        // Layout
        Navigator.pushNamed(context, 'LayoutListPage');
        break;
      case 2:
        // TestReorderableListView
        Navigator.pushNamed(context, 'TestReorderableListView');
        break;
      case 3:
        // button
        Navigator.pushNamed(context, 'TestButtonPage');
        break;
      case 4:
        // Dialog
        BGDialog.showGlobalDialog(context);
        // Navigator.pushNamed(context, 'TestDialogPage');
        break;
      case 5:
        // BottomSheet
        Navigator.pushNamed(context, 'SliverDemo');
        // BGBottomSheet.showGlobalBottomSheet(
        //   context: context,
        //   listData: entries,
        //   itemBuilder: (BuildContext context, int index) {
        //     return ListTile(
        //       leading: Icon(Icons.book), // 左边Icon
        //       title: Text('Entry ${entries[index]}'), // 主标题
        //       trailing: Icon(Icons.arrow_right), // 右边Icon
        //     );
        //   }
        // );
        break;
      case 6:
        print(index);
        Navigator.pushNamed(context, 'TextDemoPage');
        break;
      default:
        break;
    }
  }

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  void didUpdateWidget(covariant MyHomePage oldWidget) {
    super.didUpdateWidget(oldWidget);
    print('didUpdateWidget');
  }

  @override
  void deactivate() {
    super.deactivate();
    print('deactivate');
  }

  @override
  void dispose() {
    super.dispose();
    print('dispose');
  }

  @override
  void reassemble() {
    super.reassemble();
    print('reassemble');
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    print('didChangeDependencies');
  }
}
<file_sep>import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:hello_world/home.dart';
import 'package:hello_world/routes.dart';

void main() {
  double a = 0.29 * 100;
  double b = NumUtil.multiply(0.29, 100);
  print('结果 $a, $b');
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      initialRoute: BGRoute.initialRoute,
      routes: BGRoute.routes,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
    );
  }
}
<file_sep>// import 'package:flutter/material.dart';

// class InfiniteList extends StatefulWidget {

// }

// class _InfiniteListState extends State<InfiniteList> {
//   static const loadingTag = "##loading##"; // 表尾标记
//   var _words = <String>[loadingTag];

//   @override
//   Widget build(BuildContext context) {
//     return ListView.separated(
//       itemBuilder: (context, index) {
//         if (_words[index] == loadingTag) {
//           // 到了表尾
//           if (_words.length - 1 < 100) {
//             // 不足100条，继续获取数据
//             // 获取数据

//           }
//         } else {
//           // 已经加载了100条数据，不再获取数据
//           return Container(
//             alignment: Alignment.center,
//             padding: EdgeInsets.all(16.0),
//             child: Text('没有更多了', style: TextStyle(color: Colors.grey)),
//           );
//         }
//       },
//       separatorBuilder: null,
//       itemCount: _words.length
//     );
//   }

//   void _retrieveData() {

//   }
// }
<file_sep>import 'package:flutter/material.dart';

import 'package:hello_world/home.dart';
import 'package:hello_world/pages/school/ReorderableList.dart';
import 'package:hello_world/pages/school/buttonDemo.dart';
import 'package:hello_world/pages/school/layout/alignLayoutPage.dart';
import 'package:hello_world/pages/school/layout/centerLayoutPage.dart';
import 'package:hello_world/pages/school/layoutListPage.dart';
import 'package:hello_world/pages/school/miniGame.dart';
import 'package:hello_world/pages/school/sliverDemoPage.dart';
import 'package:hello_world/pages/school/tableViewDemoPage.dart';
import 'package:hello_world/pages/school/textDemoPage.dart';
import 'package:hello_world/state/manageByParent.dart';
import 'package:hello_world/state/manageBySelf.dart';
import 'package:hello_world/state/manageByMixed.dart';
import 'package:hello_world/list/scrollbarList.dart';
import 'package:hello_world/list/separatorList.dart';

class BGRoute {
  static final String initialRoute = "/";
  static final Map<String, WidgetBuilder> routes = {
    "/": (context) => MyHomePage(title: 'Flutter'),
    "miniGame": (context) => MiniGame(),
    "new_page": (context) => NewRoute(),
    "manageBySelf": (context) => TapboxA(),
    "manageByParent": (context) => ParentWidget(),
    "manageByMixed": (context) => ParentWidgetC(),
    "TestReorderableListView": (context) => TestReorderableListView(),
    "letterList": (context) => LetterList(),
    "separatorList": (context) => SeparatorList(),
    // Layout
    "LayoutListPage": (context) => LayoutListPage(),
    "CenterLayoutDemo": (context) => CenterLayoutDemo(),
    // "PaddingLayoutPage": (context) =>
    "AlignLayoutDemo": (context) => AlignLayoutDemo(),
    // button
    "ButtonDemo": (context) => ButtonDemo(),
    'SliverDemo': (context) => SimpleDemoPageBody(),
    'TextDemoPage': (context) => TextDemoPage(),
    // Dialog
    // "TestDialogPage": (context) =>
  };
}

class NewRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('new route')),
      body: Center(child: Text('This is a new route')),
    );
  }
}

branch_name: refs/heads/master

repo_language: Dart

repo_name: MrCodeHauler/FlutterChat


text:
<file_sep><?php
/*
 * This file is part of the Textcleaner package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Textcleaner;

class Textcleaner {

    private $options = [

        /**
         * -r rotate ... ROTATE image either clockwise or counterclockwise by 90 degrees,
         * if image aspect ratio does not match the layout mode. Choices are: cc (or
         * clockwise), ccw (or counterclockwise) and n (or none). The default is no rotation.
         *
         */
        'rotate'        =>  '-r none',

        /**
         * -l layout ... LAYOUT for determining if rotation is to be applied. The choices
         * are p (or portrait) or l (or landscape). The image will be rotated if rotate is
         * specified and the aspect ratio of the image does not match the layout chosen.
         * The default is portrait.
         *
         */
        'layout'        =>  '-l portrait',

        /**
         * -c cropoffsets ... CROPOFFSETS are the image cropping offsets after potential
         * rotate 90. Choices: one, two or four non-negative integer comma separated
         * values. One value will crop all around. Two values will crop at
         * left/right,top/bottom. Four values will crop left,top,right,bottom.
         *
         */
        'cropoffsets'   =>  '-c 0',

        /**
         * -g ... Convert the document to grayscale.
         *
         */
        'grayscale'     =>  '-g',

        /**
         * -e enhance ... ENHANCE brightness of image. The choices are: none, stretch,
         * or normalize. The default=stretch.
         *
         */
        'enhance'       =>  '-e stretch',

        /**
         * -f filtersize ... FILTERSIZE is the size of the filter used to clean up the
         * background. Values are integers>0. The filtersize needs to be larger than
         * the thickness of the writing, but the smaller the better beyond this. Making it
         * larger will increase the processing time and may lose text. The default is 15.
         *
         */
        'filtersize'    =>  '-f 15',

        /**
         * -o offset ... OFFSET is the offset threshold in percent used by the filter
         * to eliminate noise. Values are integers>=0. Values too small will leave much
         * noise and artifacts in the result. Values too large will remove too much
         * text leaving gaps. The default is 5.
         *
         * @var
         */
        'offset'        =>  '-o 5',

        /**
         * -u ... UNROTATE the image. This is limited to about 5 degrees or less.
         *
         * @var
         */
        'unrotate'      =>  '',

        /**
         * -t threshold ... THRESHOLD is the text smoothing threshold. Values are integers
         * between 0 and 100. Smaller values smooth/thicken the text more. Larger values
         * thin, but can result in gaps in the text. Nominal value is in the middle at
         * about 50. The default is to disable smoothing.
         *
         */
        'threshold'     =>  '-t 50',

        /**
         * -s sharpamt ... SHARPAMT is the amount of pixel sharpening to be applied to
         * the resulting text. Values are floats>=0. If used, it should be small
         * (suggested about 1). The default=0 (no sharpening).
         *
         */
        'sharpamt'      =>  '-s 0',

        /**
         * -S saturation ... SATURATION is the desired color saturation of the text
         * expressed as a percentage. Values are integers>=0. A value of 100 is no change.
         * Larger values will make the text colors more saturated. The default=200
         * indicates double saturation. Not applicable when -g option specified.
         *
         */
        'saturation'    =>  '-S 200',

        /**
         * -a adaptblur ... ADAPTBLUR applies an alternate text smoothing using
         * and adaptive blur. The values are floats>=0. The default=0 indicates no
         * blurring.
         *
         */
        'adaptblur'     =>  '-a 0',

        /**
         * -T ... TRIM the border around the image.
         *
         */
        'trim'          =>  '',

        /**
         * -p padamt ... PADAMT is the border pad amount in pixels. The default=0.
         *
         */
        'padamt'        =>  '-p 0',

        /**
         * -b bgcolor ... BGCOLOR is the desired background color after it has been
         * cleaned up. Any valid IM color may be use. The default is white.
         *
         */
        'bgcolor'       =>  '-b white',

        /**
         * Path of the image to be recognized
         *
         */
        'input_image'   =>  '',

        /**
         * Path of the image processed by textcleaner
         *
         */
        'output_image'  =>  'out.jpg',

        /**
         * Path of the directory that contains the image
         *
         */
        'image_dir'     =>  ''

    ];

    public function __construct($image)
    {
        $this->options['input_image'] = $image;
    }

    public function execute()
    {
        $command = $this->buildCommand();
        exec($command);
    }

    public function buildCommand()
    {
        return implode(' ', array_merge(['textcleaner'], $this->options));
    }

    public function setRotate($rotate)
    {
        $this->options['rotate'] = '-r ' . $rotate;
    }

    public function setLayout($layout)
    {
        $this->options['layout'] = '-l ' . $layout;
    }

    public function setCropoffsets($cropoffsets)
    {
        $this->options['cropoffsets'] = '-c ' . $cropoffsets;
    }

    public function setGrayscale($grayscale)
    {
        $this->options['grayscale'] = $grayscale ? '-g' : '';
    }

    public function setEnhance($enhance)
    {
        $this->options['enhance'] = '-e ' . $enhance;
    }

    public function setFiltersize($filtersize)
    {
        $this->options['filtersize'] = '-f ' . $filtersize;
    }

    public function setOffset($offset)
    {
        $this->options['offset'] = '-o ' . $offset;
    }

    public function setUnrotate($unrotate)
    {
        $this->options['unrotate'] = $unrotate ? '-u' : '';
    }

    public function setThreshold($threshold)
    {
        $this->options['threshold'] = '-t ' . $threshold;
    }

    public function setSharpamt($sharpamt)
    {
        $this->options['sharpamt'] = '-s ' . $sharpamt;
    }

    public function setSaturation($saturation)
    {
        $this->options['saturation'] = '-S ' . $saturation;
    }

    public function setAdaptblur($adaptblur)
    {
        $this->options['adaptblur'] = '-a ' . $adaptblur;
    }

    public function setTrim($trim)
    {
        $this->options['trim'] = $trim ? '-T' : '';
    }

    public function setPadamt($padamt)
    {
        $this->options['padamt'] = '-p ' . $padamt;
    }

    public function setBgcolor($bgcolor)
    {
        $this->options['bgcolor'] = '-b ' . $bgcolor;
    }

    public function setInputImage($input)
    {
        $this->options['input_image'] = $input;
    }

    public function setOutputImage($output)
    {
        $this->options['output_image'] = $output;
    }

}<file_sep><?php

/*
 * This file is part of the Textcleaner package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace phpUnitTutorial\Test;

use Textcleaner\Textcleaner;

class TextcleanerTest extends \PHPUnit_Framework_TestCase {

    public function setUp()
    {
        if (file_exists(dirname(__FILE__) . '/out.jpg')) {
            unlink (dirname(__FILE__) . '/out.jpg');
        }
    }
    public function testTextcleaner()
    {
        $textcleaner = new Textcleaner( dirname(__FILE__) . '/images/image.jpg' );
        $textcleaner->setOutputImage( dirname(__FILE__) . '/out.jpg' );
        $textcleaner->execute();

        assertFileExists( dirname(__FILE__) . '/out.jpg' );
    }

}<file_sep># textcleaner
A wrapper to work with Textcleaner, an imagemagick script to processes a scanned document of text to clean the text background

```php
$textcleaner = new Textcleaner( dirname(__FILE__) . '/images/image.jpg' );
$textcleaner->execute();
```

## Instalation
Via composer (https://packagist.org/packages/federicoginosa/textcleaner)

```
{
    "require": {
        "federicoginosa/textcleaner": ">= 1.0.0"
    }
}
```

## Dependencies

-   [Textcleaner](http://www.fmwconcepts.com/imagemagick/textcleaner/)

**IMPORTANT**: Make sure that the `textcleaner` binary is on your $PATH.
If you're running PHP on a webserver, the user may be not you, but \_www or
similar.

If you need, there is always the possibility of modify your $PATH:

$path = getenv('PATH');
putenv("PATH=$path:/usr/local/bin");

languages: Markdown PHP

repo_language: Markdown

repo_name: FedericoGinosa/textcleaner