Friday, January 28, 2011

Crab, Elk, Snowfields

The definition of insanity is doing the same thing over and over and expecting different results


Strangely enough, that's kind of similar to the definition of Monte Carlo Simulation. 


Monte Carlo simulation calculates results over and over, each time using a different set of random values from the probability functions. Depending upon the number of uncertainties and the ranges specified for them, a Monte Carlo simulation could involve thousands or tens of thousands of recalculations before it is complete.


Ok, so it's not really the same, but it IS uncanny that Einstein's famous quote made me think of Monte Carlo.

Moving on....

I drove to the beach tonight, on a "whim"-- I noticed upon returning that I felt epically more productive, and I should really sacrifice the gas for a beach night with "crab in a box" more often. I mean, that is some darn good crab-- you can tell it just came right out of the sea, it still tastes salty and fresh. 


What I want to share though is this. As I drove out, I had this strange feeling. I was listening to some music, thinking about the trees and the mountains and just how beautiful forests are (no seriously I think of that a lot) and suddenly I realized that I was RELAXED. I can't even remember the last time I felt relaxed. There's always something wearing on me-- money, school, you know, it's just my personality, I guess, I always kind of get pent up. I wondered, maybe what I have been needing all along to feel good is just to be outside in the beautiful landscape more. I mean, that's why I got into this field in the first place, right? That's why we all do it, on some level. We feel just inherently ill when we can't be surrounded by trees. I am going to try this for a while; taking daily time (not just runs, which are on roads and are good for other reasons) but daily time to just be in the forests and mountains, and more weekend time to travel to the mountains and the sea. If the cure for feeling run down is just living in a beautiful place and enjoying it more, well, that I can do!


Anyway so I will take it as a sign that this was a good thought because I had the most amazing nature experience on the way back. It was really dark and I was driving along the road with a few other cars when suddenly-- wait don't get worried, this is a good story-- suddenly something darted out in the road, but like WAY ahead of me, not where I could hit it. So I stopped and looked and it was an elk. And he just sort of stared and stopped in the road for whatever reason (if there's such a thing as "elk in the headlights" that was this elk). So I was just stopped in the road, watching this elk and he watching me, and then I kind of looked up because it was on a downhill sort of between Toledo and Blodgett, and I saw these white clouds in the sky, almost like city lights, so I was thinking, that's weird, Corvallis is a small city, there's no way it could generate that light. So the elk moved on and I started going again, just watching this white stuff, and eventually there's a part in the road where you go over a pass, which I think is Summit Pass, it's maybe like 1000 feet high? Anyway at the top I could see the white stuff better and I could see what was below it and it was the snowfields on the Cascades. The moon was breaking the clouds in just the right way that the snowfields were glowing so brightly that they were reflecting off the clouds. I mean, you have no idea how magical this was. It's literally pitch black in the coast range, but I know what's around me, and it's this beautiful, dense, epiphytic (moss-covered) doug-fir/alder/western hemlock stand with a babbling creek along the side of the road, and then I'm at the top of one of these mountains and I can see all the way across the valley (although I couldn't really see the valley itself because of the angle and some trees) and you know, probably at least 70 miles away to the first snow cap mountain from there, and they are glowing as bright as say a short of dim blue colored flash light. Also yes, it was a blue glow, the color of a swimming pool or a glacier or something. It was just incredible.


I am so fortunate to live near mountains, especially snowy ones. And I'm so fortunate that my job essentially forces me to be near forested mountains. And sometimes I forget that I am very lucky like that. But the mountains, and the elk, and the trees, and the epic crab, they remind me that this is good.



Friday, January 21, 2011

An ode to ODEs

Earlier today, Master-o-Forests asked me for help on solving a system of coupled ordinary differential equations (ODEs). I regurgitated the standard method that I'd learned in college, then, as I was driving home, it started to seem sort of unsatisfactory to me, for reasons I won't go into. Anyway, I thought for a bit, and, to keep my brain otherwise occupied while I wait for my interminable simulations to run, I scribbled down an explanation that (to me, at least) seems a little more motivated.

Here's the basic problem statement. Suppose you've got two ODEs which are coupled in the following way:
\[ \frac{dx_1}{dt} = m_1 x_1 + m_2 x_2 \]\[ \frac{dx_2}{dt} = m_3 x_1 + m_4 x_2 \]Where the $m$'s are specified (they're just numbers). How can you find an exact solution for $x_1$ and $x_2$ as a function of $t$?

First, let's identify what the complication is here. The trouble is that the time-derivatives (on the left-hand side) are expressions of both $x_1$ and $x_2$. Life would be a lot easier if this wasn't the case -- if $dx_1/dt$ just had $x_1$ on the right-hand side, then we could separate the variables and integrate, and we'd be done! Fortunately, there's a way to uncouple the system so that we do have two very simple equations. To see this, the first thing to do is gather the $m$'s into a matrix,
\[ \frac{d}{dt}\begin{bmatrix}x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} m_1 & m_2 \\ m_3 & m_4 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} \]which is written in more compact matrix notation:
\[ \frac{d\mathbf{x}}{dt} = \mathbf{M} \mathbf{x} \]Notice that we'd have an uncoupled system if M was a diagonal matrix (that is, if $m_2$ and $m_3$ were both equal to 0). Well, M isn't diagonal, but it can be diagonalized by finding its eigenvalues and eigenvectors:
\[ \mathbf{M} = \mathbf{S D S}^{-1} \]where D is diagonal (with its elements being the eigenvalues of M, which we'll call $\lambda_1$ and $\lambda_2$):
\[ \mathbf{D} = \begin{bmatrix} \lambda_1 & 0 \\ 0 & \lambda_2 \end{bmatrix} \]and S has the eigenvectors of M (we'll denote these as a and b) as its columns,
\[ \mathbf{S} = \begin{bmatrix} a_1 & b_1 \\ a_2 & b_2 \end{bmatrix} \]Plugging the diagonalized M into our equation for $d\mathbf{x}/dt$, we find
\[ \frac{d\mathbf{x}}{dt} = \mathbf{SDS}^{-1} \mathbf{x} \]and we can multiply both sides on the left by $\mathbf{S}^{-1}$:
\[ \mathbf{S}^{-1} \frac{d\mathbf{x}}{dt} = \mathbf{DS}^{-1} \mathbf{x} \]To clean up the notation, define a new vector $\mathbf{u} \equiv \mathbf{S}^{-1} \mathbf{x}$:
\[ \frac{d\mathbf{u}}{dt} = \mathbf{D} \mathbf{u} \] Which looks pretty much like our initial system of equations, with one important exception: D is diagonal! Therefore, these equations are uncoupled:
\[ \frac{du_1}{dt} = \lambda_1 u_1 \]\[ \frac{du_2}{dt} = \lambda_2 u_2 \]These are separable, so it's easy to solve for $u_1$ and $u_2$:
\[ u_1 = C_1 \mathrm{e}^{\lambda_1 t} \]\[ u_2 = C_2 \mathrm{e}^{\lambda_2 t} \]where $C_1$ and $C_2$ are as-yet-unknown constants of integration (they'll be specified by the initial conditions). Now that we know u, it's simple to also calculate x, since, by definition:
\[ \mathbf{x} = \mathbf{S u} \]So, that's our answer. It looks a little different than the usual result, but, multiplying it out explicitly, we find the general solution is written
\[ \begin{bmatrix}x_1 \\ x_2 \end{bmatrix} = C_1 \begin{bmatrix} a_1 \\ a_2 \end{bmatrix} \mathrm{e}^{\lambda_1 t} + C_2 \begin{bmatrix}b_1 \\ b_2 \end{bmatrix} \mathrm{e}^{\lambda_2 t} \]which is the expected result.

Anyway, your mileage may vary, but I thought that this makes it clearer where the exponentials in the solution come from, and why we care about diagonalizing M in the first place.

Thursday, January 20, 2011

Do not be deceived

In the movie Fight Club, the protagonist "Jack" is really Calvin from the comic strip Calvin and Hobbes:

Thursday, January 13, 2011

Models, part 2

Models get into your head.


One skill they should teach in schools is how to psychologically deal with models.

It is a strange thing. There is such tension, wanting to be able to even write a basic model to get it onto paper, and yet having it stuck in your brain. I imagine this must be what artists feel like when they are trying to make a picture, and they know what it should look like, but their hands can't make it happen. And how do we judge really good artists, but by how well they can represent reality, or the reality that they experience. Cezanne painted the same mountain over and over for 20 years, never depicting the image that was in his mind.

In the end though, we say something about some artists, "that artist, he/she has talent!" it doesn't matter if that face looks like a cube, or a real face, there's art that we see and we appreciate, because it resonates with what we know of reality. There's something inherent in artistic talent. (then there's an intellectual agreement between the producer and the consumer (viewer), but to be discussed later). The point is, there's just some people who CAN'T draw well.


My resonating fear is that I'm the kid drawing the stick figure claiming it's a bird.

No, really, it's a bird. Ask Brancusi.

Wednesday, January 12, 2011

words of the wise

"All a man needs is clean air to breathe, fresh water to drink, and salmon"- Siskyou chieftain

Models

"All models are wrong. Some models are useful."

Tuesday, January 04, 2011

plant physiologists

"Plant physiologists have two responsibilities to the public whose money supports them. One is to make profound discoveries. The other is to make useful ones."-J.B. Passioura

Monday, January 03, 2011

But what if your box was made of carbon fibers?

Or to say it in another way, you can catch a phenomena in a logical box or in a mathematical box. The logical box is coarse but strong. The mathematical box is fine-grained but flimsy. The mathematical box is a beautiful way of wrapping up the problem, but it will not hold the phenomena unless they have been caught in a logical box to begin with.
-John R. Platt