% begin preamble
\documentclass[11pt,titlepage]{article}
\usepackage[margin=1in,noheadfoot]{geometry}
\usepackage[parfill]{parskip}
\usepackage{graphicx}
\usepackage[colorlinks,urlcolor=blue]{hyperref}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{wrapfig}

\newcommand{\e}[1]{\times 10^{#1}}
\newcommand{\q}{\mathrm}
\newcommand{\where}[1][where]{\qquad\mbox{#1}\qquad}
\newcommand{\bs}[1]{\boldsymbol{#1}}
\newcommand{\bh}[1]{\hat{\boldsymbol{#1}}}
\newcommand{\bv}[1]{\vec{\boldsymbol{#1}}}
\newcommand{\bt}[1]{\tilde{\boldsymbol{#1}}}
\newcommand{\ad}{^{\dagger}}
\newcommand{\flow}[1]{\mathcal{E}_{#1}}
\newcommand{\flux}[1]{\Phi_{#1}}
\newcommand{\dslash}{d \hspace{-0.5ex}\rule[1.2ex]{0.6ex}{.1ex}}
\newcommand{\ts}{\textsuperscript}
\def\rcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{ScriptR}}$}\!\!}}
\def\brcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{BoldR}}$}\!\!}}
\def\hrcurs{{\mbox{$\hat \brcurs$}\!}}
%end preamble

\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{arrows}
\usepackage{tikz-3dplot}

\begin{document}
\begin{center}
  {\bf University of Kentucky, Physics 306 \\
    Homework \#1, Rev. A, due Wednesday, 2024-01-17 }
\end{center}

\vspace{.3 in}

{\bf 1.} Perform the following exercises in {\bf Mathematica}. The \verb|Typewriter| font \mbox{indicates command names.}

{\bf \quad a)} \verb|Plot Exp[-1/x]| and its \verb|D|\,erivatives---it transitions very smoothly to 0 for all $x<0$.

{\bf \quad b)} Find the \verb|Series| of $(1+x)^a$ about  $x=0$ to deduce the binomial expansion.

{\bf \quad c)} Build a \verb|Plot| of $x/(a^2-x^2)$ piece by piece, starting from $x^{2}$, then $a^{2}-x^{2}$, etc.

{\bf \quad d)} \verb|Plot| the functions \verb|Sin[x]|, \verb|Sin[x-a]|, \verb|Sin [x/b]|, \verb|Sin[(x-a)/b]|, \verb|Sin[x]^2|, \verb|ArcSin[x]| using your own numbers for constants $a$ and $b$.

{\bf \quad e)} Show graphically that i) $\cos^{2}(x) = (1+\cos(2x))/2$, ii) $\sin^{2}(x)=(1-\cos(2x))/2$, iii) $2\cos(x)\sin(x)=\sin(2x)$, iv) $\cos^{2}(x)+\sin^{2}(x)=1$, v) $(\cos(x)-\sin(x))(\cos(x)+\sin(x))=\cos(2x)$.

{\bf \quad f)} \verb|Manipulate| a \verb|Plot| of $f(t)=$ \verb|x0 Exp[-alpha t] Sin[w t]| with sliders for the parameters $x_{0}$, $\alpha$, $\omega$ to investigate their effect on damped oscillatory motion, and also $f(x,t)=$ \verb|Cos[x - 2 Pi t]| versus $x$ with sliding parameter $t$ to see the wave travel.

{\bf \quad g)} \verb|Solve| \verb|x^2+1==0| for $x$ and substitute \verb|x->I| into the LHS $x^2+1$ using the \verb|/.| operator.

{\bf \quad h)} Show Euler's theorem: \verb|Exp[I x]==Cos[x] + I Sin[x]| by \verb|Series| expansion of both sides.  [{\it bonus}: \verb|Solve| for $\cos(x)$ and $\sin(x)$ in terms of $e^{ix}$ and $e^{-ix}$].

{\bf \quad i)} \verb|Plot| the functions \verb|Exp[x]/2, -Exp[x]/2, Exp[-x]/2, -Exp[-x]/2| along with the hyperbolic functions \verb|Sinh[x], Cosh[x], -Sinh[x], -Cosh[x]| and compare your results with h).

{\bf \quad j)} Show that \verb|Cosh[x]^2-Sinh[x]^2| $=1$ and compare your results with e).  [{\it bonus}: Parametrically plot (x,y)=\verb|{Cos[t],Sin[t]}| and compare with \verb|{Cosh[t],Sinh[t]}|.  What is the relation to the above identities?  Thus they are called circular (elliptical) and hyperbolic functions.]

{\bf \quad k)} Show graphically that \verb|ArcSinh[y]| = \verb|Log[y+Sqrt[y^2+1]]|.  [{\it bonus}: What is \verb|Tanh| in terms of \verb|Exp|?
Compare the {\it sigmoid} functions \verb|Tanh[x]| and \verb|2/Pi ArcTan[Pi/2 x]|.]

{\bf \quad l)} [{\it bonus}: Explore plots of the matrix equation \verb|{x,y}.{{a,b},{b,c}}.{x,y}==0| for various values of $(a,b,c)$ to discover conic sections.  Calculate \verb|Det[{{a,b},{b,c}}]| for each.]

{\bf \quad m)} [{\it bonus}: Normalize the normal distribution $p(x)=$ \verb|Exp[-((x-mu)/sig)^2/2]| so that it \verb|Integrate|s to 1 over the real line $-\infty<x<\infty$.  Plot the normal distribution and the cumulative distribution $P(x)=\int_{-\infty}^{x}p(x)$ for $\mu=2$ and $\sigma=3$.]

{\bf \quad n)} [{\it bonus}: Show that the three functions $f(x,y)=$ \verb|Cos[x]{Exp[-y],Sinh[y],Cosh[y]}| are all solutions of $\nabla^{2} f=0$.  \verb|ContourPlot| the functions.]

{\bf \quad o)} [{\it bonus}: \verb|ContourPlot| the \verb|Re|, \verb|Im| parts of $f(z)= z^2=$\verb|(x + I y)^2|, \verb|Cos[z]|, \verb|Sin[z]|, \verb|Exp[z]|.]


\newpage

{\bf 2. Taylor Series} approximations allow focusing on the essential physics and analytically calculating problems with no closed form solution.

{\bf \quad a)} Calculate the Taylor series $f(x)=f(a)+f'(a)(x-a)+\frac12 f''(a)(x-a)^{2}+\frac{1}{3!}f^{(3)}(a)(x-a)^{3}+\ldots$ of $f(x)=e^{x}, ~ \cos(x), ~ \sin(x)$ to 5th order ($x^{5}$) about $a=0$  and compare with Mathematica.

{\bf \quad b)} Perform long division of $\tan(x)=\sin(x)/\cos(x)$ from the series above to obtain the expansion for $\tan(x)$ to 5th order in $x$ and compare with Mathematica.

{\bf \quad c)} Use the binomial series $(1+x)^{\alpha}=1+\frac{\alpha}{1}x+\frac{(\alpha)(\alpha-1)}{(1)(2)}x^{2}+\ldots$ to obtain the {\bf multipole expansion} of the electrostatic potential $V(\bv r) = q/4\pi\epsilon \rcurs$, where \mbox{$\rcurs=((\bv r-\bv r')\cdot(\bv r-\bv r')=r^{2}-2rr'\cos\gamma+r'^{2})^{1/2}$} to 2nd order in $r'$. \mbox{[{\it bonus}: Identify the monopole, dipole, and quadrupole moments and potentials.]}

{\bf \quad d)} In the small-area approximation, the {\bf solid angle} subtended by a detector of area $|\vec{A}|$ with unit normal $\hat{A}$ located at spherical coordinates $(R,\Theta,\Phi)$, tilted down by the angle $\Gamma$ (from facing the origin) %(Fig.~\ref{fig:3D_geometry})
is
\[
  \Omega(x,y)=\frac{\vec{A}\cdot\hat D}{D^{2}}= \frac{A}{R^{2}}\frac{\cos\Gamma - \sin(\Theta+\Gamma)(x\cos\Phi+y\sin\Phi)}{(1-2\sin\Theta(x\cos\Phi+y\sin\Phi)+x^{2}+y^{2})^{3/2}}.
\]
Expand $\Omega(x,y)$ to second order in $x$ and $y$ about the origin.  [{\it bonus}: Show that for the total solid angle of 4 symmetric detectors at azimuthal angles $\Phi=0,\pi/2,\pi,3\pi/2$, all terms vanish except $\Omega(x,y)=\Omega_{0}+\Omega_{2}(x^{2}+y^{2})$.  Calculate the relation between $\Theta$ and $\Gamma$ that forces $\Omega_{2}=0$]

\begin{figure}[h]
  \centering
  \tdplotsetmaincoords{70}{110}   % For the 3D plot.
  \begin{tikzpicture}[scale=2,tdplot_main_coords]
    
    \coordinate (O) at (0,0,0);
    % CENTER OF DETECTORS
    \tdplotsetcoord{P}{2}{45}{0}
    \tdplotsetcoord{Q}{2}{45}{90}
    
    % SOURCE POINT
    \tdplotsetcoord{X}{1}{90}{45}   % source is in xy plane
    
    % AXES
    \draw[thick,->] (0,0,0) -- (2.5,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,0,0) -- (0,2.5,0) node[anchor=north west]{$y$};
    \draw[thick,->] (0,0,0) -- (0,0,2.5) node[anchor=south]{$z$};
    
    % \tdplotsetrotatedcoordsorigin{(O)};
    % \tdplotsetrotatedcoords{0}{65}{0};    % set it back to the original
    % r VECTORS
    \draw[->,red] (O) -- (P);       % xz plane
    % \node at (0.71,0,0.71) [anchor=east]{$\vec{r_1}$};
    \draw[dashed,red] (Px) -- (P);  % z axis projection
    \tdplotsetthetaplanecoords{0};   % set Theta axis in xz
    \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{45}{}{}; % draw in Theta
    \draw[->,red] (O) -- (Q);       % yz plane
    \node at (0,0.71,0.71) [anchor=south]{$\vec{R}$};
    \draw[dashed,red] (Qy) -- (Q);  % z axis projection
    \tdplotsetthetaplanecoords{90}  % set Theta axis in yz
    \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}{45}{anchor=south west}{$\Theta$} % draw in Theta
    
    % SOURCE VECTOR
    \draw[->,blue] (O) -- (X);
    \tdplotsetcoord{x}{0.5}{90}{45};  % so I have somewhere to put the label
    \node at (x) [anchor=north east]{$\vec{X}$};
    \filldraw[color=black,fill=blue] (X) circle (1pt);
    
    % D VECTORS
    % \tdplotsetrotatedcoords{90}{45}{0}; % line up the x-axis with r1 vector
    % \tdplotsetrotatedcoordsorigin{(X)};    % set the source point as an origin
    % \tdplotsetcoord{d1}{1}{53}{13};   % so I have somewhere to put the label
    \tdplotsetcoord{d}{1}{50}{77};
    
    \draw[->,orange] (X) -- (P);
    % \node at (d1) [anchor=north]{$\vec{d_1}$};
    \draw[->,orange] (X) -- (Q);
    \node at (d) [anchor=north]{$\vec{D}$};
    
    % DETECTOR
    \tdplotsetrotatedcoordsorigin{(Q)};     % set the center of the detector as the origin
    \tdplotsetrotatedcoords{90}{25}{-90};     % line up the y-axis with where the detector is (I chose a Gamma of 20 degrees **beta goes on the last rotation**)
    \filldraw[tdplot_rotated_coords,draw=black,fill=black!20] (0.5,0.5,0) -- (0.5,-0.5,0) -- (-0.5,-0.5,0) -- (-0.5,0.5,0) -- cycle;
    \draw[tdplot_rotated_coords,dashed] (0,0.5,0) -- (0,-0.5,0);
    % \draw[tdplot_rotated_coords,dashed] (0,0,0) -- (0.5,0,0);
    \draw[->,dashed,tdplot_rotated_coords] (0,0,0) -- (0,0,0.6) node[anchor=east]{$\hat{A}$};
    
    \tdplotsetrotatedcoords{90}{-45}{-90};     % Rotate it to a Gamma of 0
    \tdplotsetrotatedthetaplanecoords{90};   % makes x'y' coplanar with plane containing Gamma (essentially making the y' axis the z'' axis; makes the z' axis the -x'' axis.. I think)
    \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.45}{90}{70}{anchor=south west}{$-\Gamma$}; % draw in Gamma
    
    \tdplotsetrotatedcoords{90}{-45}{-90};     % Rotate it to a Gamma and beta of 0 (this command rotates the original coordinate system)
    % \draw[red,dashed,tdplot_rotated_coords] (0,0,0.5) -- (0,0,0);    % r normal surface (Gamma=0)
    \draw[->,red,dashed,tdplot_rotated_coords] (0,0,0) -- (0,0.5,0);
    \tdplotsetcoord{q}{2.5}{45}{90};
    \node at (q) [anchor=north]{$\hat{R}$};   % This coordinate is in the original frame. Not sure about the syntax for specifying this coordinate frame.
    
    \tdplotsetrotatedcoordsorigin{(P)};     % set the center of the detector as the origin
    \tdplotsetrotatedcoords{0}{25}{0};  % drawing in the other for completeness
    \filldraw[tdplot_rotated_coords,draw=black,fill=black!20] (0.5,0.5,0) -- (-0.5,0.5,0) -- (-0.5,-0.5,0) -- (0.5,-0.5,0) -- cycle;
    \draw[tdplot_rotated_coords,dashed] (0.5,0,0) -- (-0.5,0,0);
%cbc    \tdplotsetcoord{a}{2.2213}{38.929}{0};
%cbc    \node at (a) [anchor=south west]{$a$};
%cbc    \tdplotsetcoord{b}{2.2213}{45}{-6.071};
%cbc    \node at (b) [anchor=east]{$b$};
    % \draw[tdplot_rotated_coords,dashed] (0,0,0) -- (0,0.5,0);
    
    % \tdplotsetrotatedcoords{0}{-65}{0};     % Rotate it to a beta of 0
    % \tdplotsetrotatedthetaplanecoords{-90}; % makes x'y' coplanar with plane containing Gamma (essentially making the y' axis the z'' axis; makes the z' axis the -x'' axis..  I think)
    % \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.35}{-90}{-110}{anchor=north}{$\beta$}; % draw in beta

    % \tdplotsetrotatedcoords{0}{-45}{90};     % Rotate it to a beta of 0  (same as Gamma=0)
    % \draw[->,cyan,dashed,tdplot_rotated_coords] (0,0,0) -- (0.5,0,0);   % phi hat (beta=0)
    % \tdplotsetcoord{phi}{2}{45}{90-70.53};
    % \node at (phi) [anchor=west]{$\hat{\phi}$};
    
    \tdplotsetrotatedcoordsorigin{(P)};
    \tdplotsetrotatedcoords{0}{45}{45};  % Rotate to align with d
    \draw[tdplot_rotated_coords,dashed,orange,->] (0,0,0) -- (-0.42,0,0.47);
    \tdplotsetcoord{dhat}{2.7}{43}{0};
    \node at (dhat) [anchor=south]{$\hat{D}$};
    
    % This is here to test rotated axes.
    % \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0.5,0,0) node[anchor=east]{$x’$};
    % \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0,0.5,0) node[anchor=north]{$y’$};
    % \draw[tdplot_rotated_coords,color=blue,thick,->] (0,0,0) -- (0,0,0.5) node[anchor=west]{$z’$};
    
  \end{tikzpicture}
  %\caption
  {\\A view of two detectors centered at $(R,\Theta,0)$ and $(R,\Theta,\pi/2)$ in spherical coordinates.}
  \label{fig:3D_geometry}
\end{figure}


\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
