Because We Can

Posted in Computing 5 years, 4 months ago

The following snippet of code is legal in C, C++, Perl, TeX, LaTeX, PostScript, sh, bash, zsh and Prolog. Just Because We Can.

%:/*:if 0;"true" +s ||true<</;#|+q|*/include<stdio.h>/*\_/
{\if(%)}newpath/Times-Roman findfont 20 scalefont setfont(
%%)pop 72 72 moveto(Just another PostScript hacker,)show((
t)}. t:-write('Just another Prolog hacker,'),nl,halt. :-t.
:-initialization(t). end_of_file. %)pop pop showpage(-: */
int main(){return 0&printf("Just another C%s hacker,\n",1%
sizeof'2'*2+"++");}/*\fi}\csname @gobble\endcsname{\egroup
\let\LaTeX\TeX\ifx}\if00\documentclass{article}\begin{doc%
ument}\fi Just another \LaTeX\ hacker,\end{document}|if 0;
/(J.*)\$sh(.*)"/,print"$1Perl$2$/"if$_.=q # hack the lang!
/
sh=sh;test $BASH_VERSION &&sh=bash;test $POSIXLY_CORRECT&&
sh=sh;test  $ZSH_VERSION && sh=zsh;awk 'BEGIN{x="%c[A%c[K"
printf(x,27,27)}';echo "Just another $sh hacker," #)pop%*/

(via ranganwald)

Phase space

Posted in Physics 5 years, 4 months ago

The emphasis for this week in my non-linear physics class was on phase space. Analysis of dynamical systems in phase space (or configuration/state space) converts a numerical problem into a geometric one. Even if you aren’t able to solve the underlying differential equation, the geometric picture helps you make predictions on the behavior of the system. From control engineering, an analogy with the Root Locus method was drawn.

pend0.png

The picture above shows the phase space for the pendulum equation:

\theta^\prime^\prime + \sin \theta = 0

Each point on the phase space acts as an initial condition for the system. As I had written earlier, solving this equation is not trivial. If instead we look at the phase plane, we can determine three distinct regions of operations:

  • fixed points at the origin and at the intersection of the two red lines. These correspond to steady states, but aren’t very interesting.
  • closed orbits around the origin. These correspond to periodic motions.
  • trajectories apart from orbits and fixed points.

Physically, we can reason that for a high initial velocity (higher up on y-axis), the period tends to infinity. The position (x-axis) also increases constantly.

First Integral

 \theta^\prime^\prime + \sin \theta = 0

 \theta^\prime \theta^\prime^\prime + \theta^\prime \sin \theta = 0

[ \frac{1}{2}  (\theta^\prime)^2]^\prime + [ -\cos \theta]^\prime = 0

[ \frac{1}{2}  (\theta^\prime)^2   -\cos \theta]^\prime = 0

which means that

 \frac{1}{2}  (\theta^\prime)^2   -\cos \theta = \epsilon

where \epsilon is a constant. These indicate level curves in the phase plane, corresponding to constant “energy.”

For non-dissipative systems, flows in phase space have constant volume. If you were to pick a circle centered around one of the periodic trajectories, representing an ensemble of trajectories, then the area (in 2D) of the circle remains constant. Ofcourse, if the trajectories are not circle (as they are near the origin), the circle we initially start with gets deformed. This can be seen in the following figure:

pendn.png

Computing the area of the circle is simple, but computing the area of the arbitrary deformed polygon is a little harder. This is the focus of the next section.

Area of a polygon

Consider a polygon of N edges with vertices (x_i,y_i). The polygon should also be closed so that (x_0,y_0) is the same vertex as (x_N,y_N). The area is given by

A = \frac{1}{2} \Sigma_{i=0}^{N-1} ( x_i y_{i+1} &#8211; x_{i+1} y_i)

This method works by projecting a line from each vertex to a horizontal line (usually the x-axis) below polygon. The area enclosed between two such line segments is the sum of the area of the triangle in the polygon and the area of the trapezoid outside the polygon. As we loop through the vertices of the polygon, the area outside the polygon eventually cancels out. This is a form of the Stokes Theorem.

Another Week

Posted in Activity 5 years, 4 months ago

I finally got my computer account with the Faculty of Applied Science (FAS) system. Our lab doesn’t have pre-determined computers for its members. You can sit at whatever computer is available at that moment. Most computer resources are remotely accessible, so it doesn’t really matter in the end. My workstation of choice is a dual Xeon processor machine with three gigs of RAM. I’ve never seen programs (specially firefox) startup so instantaneously. It’s great.

I’m still familiarizing myself with some of the terms that get thrown around so frequently. There are a lot of posters on the walls around the lab — I’ve been talking to people about them. A major theme seems to be quantifying diseases with deformations in body parts – specially the brain. We are still long ways from letting a computer do diagnosis though.

This lab is truly a multi-disciplinary one. People around me are taking classes in physiology, machine learning, signal processing and general anatomy. And non-linear physics. Some of the sample projects I’ve looked at is quite demanding on multiple levels. Start from the acquisition process in the clinics for data to all the way down to representing tensors in your programs. I don’t fully understand the scope of the projects to pick one, so I’ll have to do some more background reading.

On Friday, we had a talk by Dr. John Aldrich from the radiology department at the Vancouver General Hospital. His talk was on optimizing Computed Tomography for clinical studies. CT accounts for more than 60% of the radiation dose to patients in the hospital setting. Studies have shown that the dosage variation for the same examination can vary upto a factor of ten, ie 1000%.

I = I_0 \exp{(-\mu d)}

The first part of his talk was on the basics of CT. When a X-ray is shot through the body, it undergoes dissipation. Sensors on the other side of the body measure the resulting intensity of the wave. Using this, we can compute the value of \mu, the dissipation constant. This is a function of the density of the material. This is how we can differentiate bones from tissues.

He then went on to the latest-and-greatest of CT machines. He compared designs from Siemens and Toshiba and the difference in methodology. One is optimized for acquisition time while the other is optimized for higher resolution.

The second half of his talk was on optimizing CT examinations. As mentioned earlier, radiation can vary significantly between examinations. Radiation from CT machines can pose a significant cancer risk. What Dr. Aldrich has done is optimize the radiation dosage intensity as a function of noise levels. It’s enough to maintain radiation levels just above a certain noise threshold so that diagnosis is possible. Anything more is not necessary.