Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Saturday, December 3, 2011

Mathematics and MathJax

You know how I'm always saying \(\LaTeX\) makes math look beautiful? Well, yesterday I stumbled upon a way to get that same look in HTML. It's called MathJax, and it's really quite neat. All you have to do is link a JavaScript script in the header of your webpage (accomplished by editing my Blogger template), and the script will go through and convert any \(\LaTeX\) formatting into proper HTML that should be able to be rendered by any browser.

With MathJax, you can have inline equations like \(a^2+b^2=c^2\), or equations displayed with their own focus, like this:
\[ x = {-b\pm\sqrt{b^2-4ac}\over2a}\tag{1}\]
\[e^{i\pi}+1=0 \tag{2}\]
((1) is the quadratic formula; (2) is Euler's Identity)

This happens to be extremely fortuitous, because I was just thinking of writing a post with some calculus in it, and was pondering how to get the equations in. Now with MathJax, I'll be able to write a lot more about math in the future.

Edit (12/4/11): In case anyone would like to use MathJax in their own blog (or other website), here's how to do it. You need to put a line linking to the MathJax script in the header of your site. To accomplish that with Blogger, you need to access your blog's template (the easiest way to do that is to click on the "Design" link at the top right of the screen). Once there, click on the "Edit HTML" button. It'll bring up a dialog reminding you that can seriously mess up your blog if you don't don't know what you're doing. Click "Proceed", whereupon you'll be able to see the code underlying you blog. Once there just paste the following code somewhere in the header of your template; I'd suggest putting right before the line with "<b:skin><![CDATA[/*".
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ TeX: { extensions: ["autobold.js"] }});
</script>
<script type="text/javascript"
    src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
Note that by default this script doesn't process AMS (American Mathematical Society) symbols or commands. Since the AMS packages are very helpful, there's an easy way to include them. Simply add the following options to the "extensions" list, right after "autobold.js".
"AMSmath.js", "AMSsymbols.js"
That should be it! Try writing some \(\LaTeX\) expressions enclosed in either
\(...\)
or
\[...\]
for inline and displayed math, respectively. Check out the MathJax webpage if you need more help or information.

Sunday, August 28, 2011

Daniel's Software Musings (Part 2)

Today in the second part of my software-review series I have another couple of programs for you to peruse and (hopefully) enjoy.


Creativity
Audacity
Audacity is an excellent sound editing program. That sounds trite, but there really isn't that much more I can say about it. It does sound editing, and it does it well. I don't do a lot of sound editing compared to, say, photo editing, but on the occasions I have I've found Audacity to be quite capable of what I needed it to do. One minor caveat: although Audacity can read MP3 files just fine, it cannot save your work as one without downloading a separate plugin (this has to do with software patents preventing the bundling of the pertinent code with Audacity, although the use of the plugin itself is completely legal). Thankfully the installation process is fairly simple, and there are full instructions for how to do it in the FAQ. And there's a good chance you will want to do it, given the ubiquity of MP3 files nowadays....

Productivity
TeXworks (\(\LaTeX\))
I know I've gushed before about how \(\LaTeX\) makes your documents look beautiful, but I just couldn't resist the chance to do it again. For those who don't know, \(\LaTeX\) (pronounced lay-tech, with a Greek chi (\(\chi\)) sound at the end if you want to be particular) is a sort of easier-to-use version of \(\TeX\). \(\TeX\) is a typesetting language invented by the brilliant computer scientist Donald Knuth himself, and TeXworks is a program that interprets documents written in \(\LaTeX\) format and outputs them as PDF documents. Like many of the programs I'll be listing, it requires an investment of time in order to use well, but the results are worth it. To be clear, TeXworks is but one of many \(\LaTeX\) editors out there, but it's a good one, and more importantly, it's free, unlike a lot of them. (To explain, \(\LaTeX\) is like HTML; it's a mark-up language that must be interpreted. TeXworks is to \(\LaTeX\) what your browser is to HTML.) There really is no better way to describe \(\LaTeX\) than that it takes what you type and makes it beautiful, leaving you free to concentrate on the substance rather than the style of what you're writing (unlike these posts, where I have to do a lot of manual HTML and CSS tweaking to get those fancy header effects). And it's not only math-heavy papers that benefit from it (although they do, tremendously). It's possible to display pretty much any symbol ever devised or invented by man using \(\LaTeX\). The intimidatingly-large document that lists every symbol supported includes everything from specialized phonetic symbols to musical notation to Egyptian hieroglyphics to pigpen-code fonts to chess notation to ancient alchemical symbols to Feynman diagram notation to the entirety of the still-undeciphered Minoan script Linear, A and B. And just in case that wasn't enough for you, there's a large section at the end detailing exactly how to go about defining and using your own symbols. And I haven't even mentioned one of the most amazing thing about \(\LaTeX\) that should appeal to everyone who's ever had to write a bibliography: \(\LaTeX\) can write it for you. You just put the information for your papers into a database (and many papers found online come with that information handily pre-generated), and \(\LaTeX\) can create a complete database out of it in many different standard formats using just two commands. It's that simple. If you foresee any large amounts of writing in your future, do yourself a favor and learn how \(\LaTeX\) can make life simpler (and more beautiful) for you.

Miscellaneous
WizMouse
Have you ever found yourself with two windows open, perhaps comparing or copying things between them, when all of a sudden you need to scroll the window that you aren't currently working in? I don't know about you, but that happens to me a lot (especially while using TeXworks), and I find the constant need to click over to the inactive window, scroll, then click back and re-locate my place in the first window again a pain. Wouldn't it be nice if you could just scroll the inactive window without having to click on it first? If you answered yes, well, then, rejoice! because WizMouse allows you to do just that. Honestly, this program does what Windows should be doing natively. You'll notice I specifically said Windows there, because both Macintosh and Linux do this already, and it's a real black mark for Microsoft that they haven't yet caught up to the 21st century. It's not difficult, as shown by the tiny size of the file necessary to do it. Some of you know me as a staunch anti-Apple person, but I will willingly concede that in this area Apple is way ahead of the makers of my favorite operating system. Anyway, the point is, this program fixes it. Get it. Unless you're not running Windows, of course.

And that's it for another episode! I don't know how, but I sit down to write one of these after supper and next thing I know it's the wee hours of the morning, so I hope you appreciate it. A hui hou!

Thursday, November 25, 2010

Happy Thanksgiving!

Hauʻoli Lā Hoʻomaikaʻi kākou!

Happy Thanksgiving everyone! Here's hoping the day finds you with even more to be thankful for than I. The weather here is gorgeous, brilliant sunshine enthusiastically punctuated periodically by short downpours. I am blessed with a loving family, sufficient food to eat, and academic success. I love my work, and get to regularly experience the beauty of the created order. My life is not worry or trouble free (whose is?), but today is a good day to gain a little perspective on just how minuscule my problems are in comparison to my blessings.

I encourage everyone to take a little time today to enumerate the set of all your blessings. (Being potentially infinite, you'll have to terminate it after a fixed number of terms, but the exercise is diminished in worth thereby not one iota.)

By the way, the Hawaiian term given above for Thanksgiving, Lā Hoʻomaikaʻi, translates pretty freely as “day of thanksgiving”. There is, however, another more informal term that could also be used: Hauʻoli Lā ʻAi Pelehū. What's that translate as, you ask?

Happy Turkey Eatin’ Day, y’all!

(I'm also thankful I learned how to use the ‘text-shadow’ HTML tag today!)

Thursday, May 27, 2010

A tour of Subaru.

Tuesday, nine of us from the University Astrophysics Club got to go on a special tour of the Subaru telescope on Mauna Kea, which at 8.2 meters in diameter is among the largest telescopes in the world (the fact that it's a single piece of glass makes it even more amazing) . I was particularly excited because the trip gave me a chance to try out my new tripod. I'll just show you the panorama I took with it now, so I can focus on the telescope for the rest of this post:

Edit (3/30/18): The original panorama here was pretty clunky (terrible exposure differences over the image, greater than 360° coverage, etcetera), so I've substituted a version I recreated with Hugin. You can still see the original version by mousing over the image, though!

Mauna Loa, Hualālai, and Mauna Kea.
We all headed up to Mauna Kea in the morning, spent a half-hour at the Vis acclimating to the elevation, and reached the top of the mountain a bit before noon. We were then taken in to the telescope control building, and thence to the telescope enclosure itself (I can't call it a dome, because it's a cylinder; there's a picture of it later).

None of my pictures can adequately convey the feeling I got being in the room with the telescope. The thing is monstrously huge. Strangely, it seems even larger than Keck to me, though that's probably because I've never stood directly beneath Keck (I'm sure it would seem plenty big then).
Here's a picture of Subaru after they graciously rotated it so that we could see the mirror (well, actually we can see the mirror cover in this shot, they had it covered for protection, but it still gives you an idea of its massiveness).

Can you find me in this picture? Hint: near the bottom.
Perhaps this will help:

Look ma! One hand!
If you're wondering why the telescope is blue, it's because the Pleiades are faintly blue colored, and 'Subaru' is the Japanese word used to refer to the Pleiades.

As you can see, it was pretty cold in there. It was 50 degrees F at the Vis when we got there, quite a bit colder than that at the summit, and even colder in the telescope enclosure (most of the major telescopes are kept at or below freezing during the day to reduce thermal expansion stresses and minimize the time to thermal equilibrium in the evenings).

This being more than a mere tourists' tour, we got to go into the workshop where they periodically re-aluminize the mirror:


The tracks you see run all the way around the room, which is circular and directly below the telescope. In the background you can see some of the equipment they have for handling the 22.8 metric ton mirror when they bring it down. I asked how much aluminum is needed to aluminize the entire 8.2 meter mirror (~53 square meters), and was told "a few grams -- the amount in one aluminum soda can" -- they just spread it really, really, thin (and smooth). I also learned that aluminum reacts with concentrated hydrochloric acid, which surprised me because I was under the impression that it didn't (that's how they strip the old coating off the mirror to re-coat it).
Finally, the obligatory group photo afterwards with Subaru in the background:

See what I mean by cylindrical dome?

The fact that the tour was of Subaru didn't stop me from getting some great pictures of some of the other observatories up there. Here's a rather pretty shot of the Sub-Millimeter Array:


I also couldn't resist taking this fortuitous shot of Keck II with its door open (I have no idea why they were, but it allowed this excellent shot):


Inside you can see the 10-meter mirror.

So... as you can see I'm managing to keep busy. I'm still happily working with Dr. Takamiya, and I finally realized what it is I like so much about my job vocation. It's the creative aspect, where each project is a challenge to be met and overcome with creativity and ingenuity. I'm happy when I have a design objective firmly in mind and the inkling of an idea about how to achieve it (though I'm even happier when I've hammered it out and it works like it's supposed to!). Right now, for instance, I'm in the process of writing a script that will iterate through our special 'cube' data files and extract all 225 individual spectra in each one, then search them all and categorize which spectral lines that interest us are present. I'm at the point where I need to come up with a way to catalog the output about each spectrum, and I have an inkling about how to write a webpage using HTML and JavaScript that would allow the Python I'm using for the script to interact with it and automatically fill out a table with the desired values. Will it work? I don't know yet, but I'm going to find out soon! And with that said, I'll close off here and get to work on it.

Ah, the joy of creating...