Archive for January, 2007

Because We Can

Posted in Computing 1 year, 11 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 1 year, 11 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} - 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 1 year, 11 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.

Library Thing

Posted in Web 1 year, 12 months ago

Books

I recently came across a service to keep track of your books. I found the site really easy to use. In my opinion, a tool is great if it gets out of your way. They’ve made good use of AJAX to update search results — I really like that. Amazon should implement something like that.

I haven’t explored the “social” aspects of the site yet (so much for my social skills.) From the looks of it, I can look up what other people with similar interests as mine read.

I often look up books from the SFU library at home. I then have to write down the call number and take it with me to campus. Now, with this service, I can add it to my LibraryThing account and problem solved. Internet access is almost universally available on campus.

Another point of interest is that abebooks has a 40% stake in the company. I’ve been using abebooks for many years now to order cheap books, sometimes only 20% the cost of a new North American edition.

Check out my profile.

First day

Posted in Physics 1 year, 12 months ago

Today was the first official day of classes.

My non-linear physics class (PHY484) has just three students. This course is cross-listed with a graduate course (PHYS848) and has one student. That makes four students. Dr. Bechhoefer, my instructor has more or less combined the course with a math course - “The Mathematical Origins of Patterns” by Dr. Muraki. That brings in another five students. Fun.

After we got past the administrative details, Dr. Bechhoefer gave us examples of patterns we see in nature. Because of the multi-disciplinary nature of this course, not all students have the same background. I’m the only engineer in the crowd. We were asked to fill out a three page survey so that the professors can better understand the backgrounds and strengths of the class. Obviously, I took this opportunity to state what I expected to learn from this course: dynamics. Be it fluid dynamics, molecular dynamics, agent based economics or chemistry, hopefully the analysis is transferable between problem domains.

The first class was a “warmup” session, barely leading into the classification of dynamical systems. Broadly, we have two kinds based on the equations of motion:

  • Differential Equations (ordinary and partial)
  • Iterated Maps (also known as difference equations)

The only difference between the two is whether time is continuous or not. Obviously, iterated maps (with discrete time) translate to computer programs quite easily.

I guess the rest of the week will be looking at trajectories in phase space. Allow me to share this “riddle” that I was once asked when discussing phase space with a friend:

A one-dimensional harmonic oscillator demonstrates oscillations, but one-dimensional systems do not undergo oscillatory motions. What’s wrong?

The answer is that the phase space of the one-dimensional oscillator is actually two-dimensional (space and the first derivative of space.) It is one-dimensional in only space.

The rest of the day was spent running around getting paperwork done. The MIAL is co-directed by people from computing science and engineering, so things are a bit scattered around. Hopefully, all of this is settled by the end of this week.