Optimization

I’m taking the DG course this semester, and most of the homework involve programming the scheme discussed that week. For the first few assignments, my algorithm was to consider each element in a for loop. It made for some very readable code, but was incredibly slow. Essentially, for each time step, I looped through each element individually and applied the appropriate scheme. It broke a lot of rules for fast computing, especially the one about not using too many for loops if possible.

This worked fine for a conservative equation, as the CFL number is reasonable. When we moved to a diffusive equation, the number of time steps had to be squared. Now the run-time was unacceptable. What I did was first try to optimize what I had. I think my total speedup was roughly 20

Finally, I bit the bullet and re-designed the whole code. I relied on matrix multiplication to construct the right hand side (which was actually taking the most time, as it changes each time). The program is far less readable, but the speedup was 100 times.

Moral? Chase after the 80

Columbus Day (Book)

It’s been a few years since I read the Hitcherhiker’s guide series, and I still remember fondly ridiculousness of the novel; science fiction and humor can mix. The Columbus Day book though… is a bit awkward with its jokes.

The premise is simple: aliens invade Earth, and overwhelming technology pound all the nations down. Another alien race arrives to defend the invaders, but apparently they’re the wrong side to fight for. It’s a really intriguing plot line to start with, that doesn’t need humor in the first place, but the way the author went with it is disappointing.

The author introduced a Marvin-esque AI (except it’s more chippy) a quarter of the way through the book, and used that as an ex machina for everything the humans do. Instead of a feel-good story about human ingenuity, we get a story about an ancient AI telling them how to do everything. Such a good plot line squandered I feel.

The language is beyond colloquial, with little prose worth mentioning. There’s also an incredibly amount of typos throughout the book (for something that highly rated on Amazon…?). Overall, a bit disappointed at how the rating system on Amazon worked on.

Mini Metro

After finishing VVVVVV, I downloaded Mini Metro from the Humble Bundle. It’s really a fun game to play, with very nice aesthetics and soundtrack. If you want a nerd’s opinion, there’s even some graph theory I reckon that one needs to fully optimize the game.

 

Growing Pains

For all the advancements in medical science, the lower back still seems to tread in the Dark Ages. I sprained my lower back three weeks ago, and all the resources online seems to indicate to be extremely careful as there’s no surefire way to treat the pain. That’s scary.

I’ve never really considered how aging will affect my physical health till now. From a tweaked shoulder, to now some back pain, I really need to watch out when I exercise.

The Tower of Babel

I initially intended to blog to make tons of money. That didn’t pan out well, so I’ve changed my goals to things more manageable. For one, it’s a tool for me to survey my mental fortitude at the time of writing. Posts tend to get depressing as I go through rough phases of life. Otherwise, it serves as a tool to memorialize my life.

Recently, I’ve realized my writing skills are decaying. Forcing myself to write helps to sustain what I’ve built up in my undergrad years. But this is all in English, and does little to help with communicating in Chinese. Truth is, the vast majority of my family only really speaks Chinese. Isn’t it ironic that the children of immigrants gradually lose the language that connects them with their roots?

I’m glad there are others who voice this opinion. I hope your rest is peaceful.

Media and Entertainment

Two notes

  1. Just finished “The Things We Wish Were True,” which was one of the Kindle first selection. In a lot of aspects, it was very similar to A Spool of Blue Thread: white, American families with a lot of complexity lying behind their histories. The two books used those secrets to advance the plots, which mostly consisted of… fairly typical stuff in the case of TTWWWT, with a small twist at the end.

    Overall, the book just seems to move along so slowly with a writing style that’s not as beautiful as I wanted it to. Oh well.

  2. Batman Lego is pretty hilarious…

Winter

Out of the bosom of the Air,
      Out of the cloud-folds of her garments shaken,
Over the woodlands brown and bare,
      Over the harvest-fields forsaken,
            Silent, and soft, and slow
            Descends the snow.

Even as our cloudy fancies take
      Suddenly shape in some divine expression,
Even as the troubled heart doth make
      In the white countenance confession,
            The troubled sky reveals
            The grief it feels.

This is the poem of the air,
      Slowly in silent syllables recorded;
This is the secret of despair,
      Long in its cloudy bosom hoarded,
            Now whispered and revealed
            To wood and field.

– Henry Wadsworth Longfellow

Simple Verification of Mass Matrix

Verifying a stiffness matrix isn’t too hard. See the following PDF file. Otherwise, once a stiffness matrix have been verified, the mass matrix can be too with a few lines more code.

Instead of a Poisson problem, discretize the heat equation such that the steady state is our Poisson problem with an easy time stepper (say Euler). Note that we will have to invert our mass matrix at each step and have a mass matrix multiply. Then we should see that the solution dotted with the force vector approaches the same value as above.

Musings

As it turns out, the DG homework wasn’t that ridiculous. If you stripped everything down, and use a little bit of built-in numerical quadrature, then it was actually pretty fun. It turns out that programming all these solvers naturally lends itself to a abstract class with abstract methods paradigm with a few main functions (i.e. solve) that seems to be shared between all the problems.

On another note, I really fucked up meatloafs today. Didn’t season well (bland as ever) with too little bread and zero eggs (whoops, lesson learned). In the end, it was a bland piece of beef which fell apart very easily.

Finally, my god was the Aussie final spectacular. Federer’s backhand was immaculate, arguably better than 2006-2010 levels. Nadal’s passing shots were insane, forcing Federer to hit from the baseline.

Kubo

I’ve wanted to watch “Kubo” for a few weeks now, but with the recent gif popping up… it just makes it so much cooler. How many people in the world have the technically and modelling know-how to do this… it’s mind blowing.

View post on imgur.com