# Tutor profile: Jim L.

## Questions

### Subject: Physics (Newtonian Mechanics)

A tube of length, L, rotates about one end in the horizontal plane with a constant angular velocity, $$\Omega$$. The rotation is about the vertical axis. A particle of mass, m, is released in the tube from a radial distance of L/2. Find the radial and transverse components of velocity as the particle exits the end of the tube.

We start by setting up our coordinate systems. In the inertial frame, N, the x and y axes are found in the horizontal plane, and the z axis is vertical. We attach a reference frame to the rotating tube as well. $$\hat{e}_r$$ is a unit vector that is parallel to the tube, $$\hat{e}_\t$$ is in the horizontal plane, perpendicular to the tube, pointing in the direction of rotation, and $$\hat{e}_n$$ is normal to the horizontal plane, pointing in the same direction as the inertial z axis. The radial (r), tangential (t), and normal (n) coordinate axes will be used to develop the acceleration , velocity, and position of the particle. The angular velocity of the Tube (T) in the inertial frame (N) is said to be constant, and is expressed as: $$^N\vec{\omega}^T = \Omega \hat{e}_n$$ The position of the ball can be expressed quite simply in the r,t,n coordinate frame as: $$\vec{r}_{P/O} = r \hat{e}_r $$ Here, we define P = point coincident with particle, and O = center of rotation of the tube. We take the derivative of the position vector with respect to time to determine the velocity vector: $$^N\vec{v}_{P} = \frac{^N d r \hat{e}_r}{dt} = \dot{r} \hat{e}_r + r \dot{\hat{e}}_r = \dot{r} \hat{e}_r + r \cdot {^N\vec{\omega}^T} \times \hat{e}_r =\dot{r} \hat{e}_r + \Omega r \hat{e}_t $$ Here, we made use of the kinematic relationship for unit vectors in rotating frames: $$\dot{\hat{e}} = \omega \times \hat{e}$$ We apply the vector differentiation formula to compute the acceleration of the particle in the inertial frame: $$ ^N\vec{a}_{P} = \frac{^Nd(^N\vec{v}_{P})}{dt} = \frac{^Td(^N\vec{v}_{P})}{dt} + ^N\vec{\omega}^T \times ^N\vec{v}_{P} $$ Substituting ... $$^N\vec{a}_{P} = \frac{^Td(\dot{r}\hat{e}_r + \Omega r \hat{e}_t)}{dt} + (\Omega \hat{e}_n) \times (\dot{r}\hat{e}_r + \Omega r \hat{e}_t) $$ We make use of the cyclical cross product relationships: $$\hat{e}_r \times \hat{e}_t = \hat{e}_n$$, $$\hat{e}_t \times \hat{e}_n = \hat{e}_r$$, and $$\hat{e}_n \times \hat{e}_r = \hat{e}_t$$ to expand the cross product above. We also take advantage of the fact that $$\Omega$$ is constant. Assembling terms along the component directions we get the following expression for the acceleration of the particle: $$ ^N\vec{a}_{P} = ( \ddot{r} - \Omega^2r) \hat{e}_r + 2\Omega \dot{r} \hat{e}_t $$ The particle is subject to transverse reaction forces from the tube, but there are no forces along the radial direction. So when we write our particle dynamics equation, $$\vec{F} = m \vec{a}$$, we have: $$\left(\begin{array}{c} 0 \\ R_{transverse} \end{array} \right) = m \cdot \left(\begin{array}{c} \ddot{r} - \omega^2r \\ 2\omega \dot{r} \end{array} \right) $$ Only, the radial component matters to the solution of the tube exit conditions (at $$ r = L $$). The radial component of the vector equation reduces to the following linear second order homogeneous differential equation: $$ \ddot{r} - \Omega^2 r = 0 $$ The general solution to this equation is of the form: $$r(t) = A e^{\Omega t} + B e^{-\Omega t}$$ Also, $$\dot{r}(t) = A \Omega e^{\Omega t} - B \Omega e^{-\Omega t}$$ We use the initial conditions to solve for the constants $$A$$ and $$B$$: $$r(0) = \frac{L}{2} = A + B $$ Also, $$\dot{r}(0) = 0 = A - B$$ This gives us: $$A = B = L/4$$. So... $$r(t) = {L \over 4} ( e^{\Omega t} + e^{-\Omega t})$$ and $$ \dot{r}(t) = { \Omega L \over 4} (e^{\Omega t} - e^{-\Omega t})$$ We make note that the exponential sums appearing in our solution for r and $$\dot{r}$$ are related to the hyperbolic trigonometric functions $$cosh(x) = (e^x+e^{-x})/2$$ and $$sinh(x) = (e^x-e^{-x})/2$$ Yielding: $$\boxed{r(t) = {L \over 2} \cosh( \Omega t) }$$ and $$\boxed{\dot{r}(t) = { \Omega L \over 2} \sinh(\Omega t) } $$ To compute the exit velocity, we first compute the exit angle ($$\Omega T$$) by applying the end condition to the position equation: $$r(T) = {L \over 2} \cosh( \Omega T) = L$$ Our exit radial position condition yields: $$ \cosh( \Omega T) = 2 $$ The so-called Pythagorean identity for hyperbolic trigonometric functions is $$ cosh^2(x) + sinh^2(x) = 1$$. Since $$ \cosh( \Omega T) = 2 $$, we have: $$sinh^2 (\Omega T) = 3$$ Substituting into our $$\dot{r}$$ equation gives our exit radial velocity: $$ \dot{r}(T) = { \Omega L \over 2} \sinh(\Omega T) = { \Omega L \over 2} \sqrt{3}$$ Recalling our velocity vector equation from above, we can compute the exit velocity we seek: $$^N\vec{v}_{P}(T) =\dot{r}(T) \hat{e}_r + \Omega r(T) \hat{e}_t = { \Omega L \over 2} \sqrt{3}\hat{e}_r + \Omega L \hat{e}_t $$

### Subject: Calculus

Evaluate the integral, $$\int e^{-x^2} dx $$.

This is an eminently useful, but deceptively simple integral. It finds use in the evaluation of probabilities resulting from a normal distribution. The student will come to quickly realize that there is no immediately available u-substitution, nor is there an apparent antiderivative of $$e^{-x^2}$$. Integration by parts gets us nowhere fast. So, how does one compute the indefinite integral? One, must resort to a series solution. We first note that the McLaurin series of $$e^u$$ is given by: $$e^u = 1 + \frac{u}{1} + \frac{u^2}{2!} + ... + \frac{u^n}{n!} + ... $$ This series has an infinite radius of convergence. Thus, $$e^{-x^2} = 1 + \frac{-x^2}{1} + \frac{({-x^2})^2}{2!} + ... + \frac{({-x^2})^n}{n!} + ... $$ or, $$e^{-x^2} = \sum_0^\infty (-1)^n \frac{x^{2n}}{n!} $$ While we cannot integrate the function directly, we can integrate the series... $$\int e^{-x^2} dx = \int \sum_0^\infty (-1)^n \frac{x^{2n}}{n!} dx $$ We can reverse the order of the appearance of the integral and the sum (as the integral of a sum is equal to the sum of the integrals): $$\int e^{-x^2} dx = \sum_0^\infty \int (-1)^n \frac{x^{2n}}{n!} dx $$ Factoring out the constants from the integral gives us: $$\int e^{-x^2} dx = \sum_0^\infty \frac{(-1)^n}{n!} \int x^{2n} dx $$ Using the polynomial rule of integration gives us the following series solution for the desired indefinite integral: $$\int e^{-x^2} dx = \sum_0^\infty \frac{(-1)^n}{n!} \frac{x^{2n+1}}{2n+1} + C $$ The series can be shown to converge for all x by the ratio test as follows: $$ | \frac{a_{n+1}}{a_n} | = \frac{x^{2(n+1)+1}}{(n+1)!(2(n+1)+1)}\cdot \frac{n!(2n+1)}{x^{2n+1}} = \frac{x^2 (2n+1)}{(n+1)(2n+3)} = \frac{x^2 (2+1/n)}{(n+1)(2+3/n)} \rightarrow \frac{x^2}{(n+1)} \rightarrow 0 < 1 $$ Thus, the series appearing in the indefinite integral has an infinite radius of convergence.

### Subject: C++ Programming

The operation of splitting a string into tokens separated by delimiters (like spaces, tabs or commas), is so common, it is supported by the string object of virtually every language. C++ stands as one of the exceptions to this. How would you write a function that accepts a string, and a single character delimiter, and returns a vector containing a list of tokens from the string?

To accomplish this programming task, we must be familiar with the C++ string and vector libraries as well as looping. Our approach to this task is as follows: a. We will maintain an instance of a token string. (It is initialized as an empty string.) b. We will loop through each character of the input text. i) If the character is not a delimiter character, then we add it to the token string ii) If the character is a delimiter character and our token is not empty, we add the token to the vector and reset the token. c. After we have looped through all of the characters, we should not forget to check the token for characters!! Add it to the vector if it has data in it. The complete annotated solution is given below: #include<vector> #include<string> std::vector<std::string> split(const std::string intext, const char delim) { std::vector<std::string> answer; // This will hold the vector of tokens from intext std::string token = ""; // We build up the tokens one at a time and store here for(auto &ch : intext) // The auto specifier allows a streamlined for loop { // which allows ch to loop through each character in intext if(ch != delim) { token = token + ch; // Each non-delimiter character is added to current token } else if(!token.empty()) { // If we see a delimiter character and our token is not empty, we add it to our vector answer.push_back(token); // Reset the token after each delimiter token = ""; } } // Common mistake -- get to the end of the loop and forget that there may be // characters in our current token!! if(!token.empty()) { answer.push_back(token); } // Pass answer vector back to client return answer; } In this implementation, I chose the for(auto) looping mechanism. This is not the only available option. A more common choice (though less efficient) is to loop through the character indices as follows: for(size_t i=0; i < intext.size(); ++i) { char ch = intext[i]; ... } Another technique is to use an iterator: for(string::iterator it = intext.begin(); it != intext.end(); ++it) { char ch = *it; ... } Happy coding!

## Contact tutor

needs and Jim will reply soon.