I am using the enumerate
environment to do homework. In the following, first I write out the question, then I write out the answers to the first two parts.
What I'd like to do is have a box around the question. How can I do that?
I tried using tikzmark
as suggested here but it did not work (the box shows up in the wrong place when I try to use math mode. See the code at the end of the article
\documentclass{article}
\usepackage{amsthm, amssymb, amsfonts, amsmath}
\begin{document}
\begin{enumerate}
\item[1.]
Consider the initial value problem
\[
\frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
\begin{enumerate}
\item[(a)] Find a solution to the problem.
\item[(b)] Regardless of (a), is the solution unique?
\item[(c)] Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
\item[(d)] Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$.
\end{enumerate}
\item[1a.]
$\phi(x) = x$ is a solution, since $$\phi'(x) = 1 = 1 - (x-x)^2.$$
\item[1b.]
Note that the function $1-(y-x)^2$ is $C^{\infty}$ in both $x$ and $y$, and therefore given $x_0$, the function is locally Lipschitz in $y$, uniformly with respect to $x$ for $x$ in a neighborhood of $x_0$. Therefore such a solution is unique.
\end{enumerate}
\end{document}
Using the tikzmark
idea (didn't work)
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{enumerate}
\item[\tikzmark{bl} 1.]
Consider the initial value problem
\[
\frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
\begin{enumerate}
\item[(a)] Find a solution to the problem.
\item[(b)] Regardless of (a), is the solution unique?
\item[(c)] Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
\item[(d)] Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$.
\end{enumerate}
\tikzmark{br}
\item[2.] Something not boxed
\item[3.] Also not boxed.
\end{enumerate}
\tikz[overlay,remember picture]{\draw[red]
($(bl)+(-0.2em,0.9em)$) rectangle
($(br)+(0.2em,-0.3em)$);}
\end{document}
Edit: A problem came when I tried to apply the suggestion given below. tikzmark
always wants to put the box on the last page. So if the document is only one page, it is fine. But if it jumps to two pages, it is wrong.
\documentclass{article}
\usepackage{tikz}
\usepackage{enumitem}
\usepackage{amsmath}
\usetikzlibrary{calc,shapes}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\begin{document}
\begin{enumerate}
\item
\leavevmode
\strut
\vadjust{%%
\noindent
\raisebox{\dimexpr\dp\strutbox+\ht\strutbox+1ex}[0pt][0pt]{\tikzmark{bl}}}%%
Consider the initial value problem
\[
\frac{dy}{dx} = 1- (y-x)^2, \qquad y=0 \,\, \text{at} \,\, x=0
\]
\begin{enumerate}
\item Find a solution to the problem.
\item Regardless of (a), is the solution unique?
\item Write down the Picard iteration scheme for this ODE and find some $r>0$ for which it converges $|x|<r$.
\item Find some $R>0$ such that the Picard iterates \textit{diverge} for $|x|>R$.
\end{enumerate}
\leavevmode
\vadjust{%
\noindent
\hspace*{\dimexpr\textwidth+1ex}\tikzmark{br}}%%
\item[1a.]
$\phi(x) = x$ is a solution, since $$\phi'(x) = 1 = 1 - (x-x)^2.$$
\item[1b.]
Note that the function $1-(y-x)^2$ is $C^{\infty}$ in both $x$ and $y$, and therefore given $x_0$, the function is locally Lipschitz in $y$, uniformly with respect to $x$ for $x$ in a neighborhood of $x_0$. Therefore such a solution is unique.
\item[1c.]
For convenience of notation, let us agree to label the constant function $0$ as the first Picard iterate $y_1(x)$ rather than the $0$th Picard iterate.
\begin{align*}
y_2(x) &= \int_0^x 1 - (y_1 - \xi)^2 d\xi = x - \frac13 x^3 \\
y_3(x) &= \int_0^x 1 - (y_2(\xi) - \xi)^2 d\xi = \int_0^x 1 - \left(\frac13 \xi^3\right)^2 d\xi = x - \frac{1}{7\cdot 3^2}x^7 \\
y_4(x) &= \dotsb = x - \frac{1}{15\cdot 7^2 \cdot 3^4}x^{15}\\
\vdots \\
y_n(x) &= x - \frac{1}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}} x^{2^n - 1}
\end{align*}
The iterates will converge pointwise for $|x|<1$ (making no claim that that is the largest such interval). Since the modulus of the second term of $y_n$ is increasing with the modulus of $x$, we can say that the iterates will converge uniformly on compact subsets of the unit interval. (Given $[-a, a]\subseteq (-1,1)$, pick $n$ such that the second term of $y_n(a)$ is less than $\epsilon$; then this $n$ will work for all $x \in [-a, a]$.)
\item[1d.]
Suppose we find an $x$ for which
\begin{align*}
x-\frac{1}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}} x^{2^n - 1}
\end{align*}
diverges to infinity (of course it will diverge iff the second term diverges). Then by the same considerations as in part (c), we can say that it will diverge for $\xi$ such that $|\xi| > |x|$.
Suppose we choose $x=4$. We have
\[
y_n(x) = 4 - \frac{2^{2(2^n-1)}}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}}.
\]
Note that the denominator satisfies
\[
(2^n-1)^{2^0}(2^{n-1}-1)^{2^1}\dotsb (2^2-1)^{2^{n-2}}\leq 2^{n2^0 + (n-1)2^1 + \dotsb + (2)2^{n-2}},
\]
where we have left out the final factor because it is equal to one. Some algebra tells us that $n2^0 + (n-1)2^1 + \dotsb + (2)2^{n-2} = 2^{n}+2^{n-1}-(n+2)\leq 2^{n+1}-(n+2)$. When we consider
\[
\frac{2^{2(2^n-1)}}{\prod_{k=1}^{n} (2^k-1)^{2^{(n-k)}}} \geq \frac{C2^{2^{n+1}}}{2^{2^{n+1}-(n+2)}}=C2^{n+2},
\]
this clearly diverges.
\item[2.] Let $y=\phi(x)$ and $y=\psi(x)$ be linearly independent solutions of the ODE $y'' + p(x)y' + q(x)y = 0$, where $p$ and $q$ are continuous on an open interval $I$. Prove the following statements:
\begin{enumerate}
\item[(a)] Suppose that $x_0 \in I$ is a zero of $\phi$, then $\psi$ cannot have a relative extremum value at $x_0$.
\item[(b)] Suppose that $x_0$ and $x_1$ are two consecutive zeros of $\phi$ in $I$. Then $\psi$ must have a zero at some $\xi$, $x_0<\xi<x_1$.
\end{enumerate}
[\textit{Hint:} Think Wronskian.]
\end{enumerate}
\tikz[overlay,remember picture]{\draw[red]
(bl) rectangle
(br);}
\end{document}
tcolorbox
.tikz
may remember the dimensions, but it doesn't necessarily remember the page it was defined on.\tikzmark
: one makes use of customizable offsets. Have a look to Enumerated text and formula with background color for a demo. However, for this I would also usetcolorbox
.exam
class and it'ssolution
environment.