Thursday, July 12, 2012

A very convenient way of using math in Blogger

Math formulas like Gauss law $\oint_S \vec{E}\cdot\vec{dS}=\frac q \epsilon_0$ have always been a headache when it came to webpages ( even Moodle does it quite badly).

But MathJax seems to solve a whole lot of different problems, is simple to use, and seems having fulfilled it's task. On the main page, you can see some eye-candy examples, there is a great FAQ, and an indispensable list of implemented LaTeX commands (there is an option of using MathML, but for me, TeX seems much more convenient, and doesn't make me learn a new language). Pay attention: \newcommand IS implemented!

It works in probably any situation you could imagine; in Blogger, you just need to insert
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
 extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js"],
 jax: ["input/TeX", "output/HTML-CSS"],
 tex2jax: {
     inlineMath: [ ['\$','$'], ["\\(","\\)"] ],
     displayMath: [ ['\$','$$'], ["\\[","\\]"] ],
     processEscapes: true },
 "HTML-CSS": { availableFonts: ["TeX"] }
});
</script>


after the </head> tag in the template HTML code (Design→Edit HTML→Edit Template). Done!


NB! If you want to define some convenient new commands, put the definitions in inline math mode in the beginning of the page, and the new commands will be available in all the formulas.


Friday, February 17, 2012

I proclaim this to be my best peace of code for quite a time

http://pastie.org/private/oxwmqtbis0zaj0dofqrgig

This R code summarizes the results of modelling a cloud of particles. The part I'm actually proud of are lines 47-54. It was fun getting used to the "vector-oriented" paradigm.