pages tagged syntax http://meng6net.localhost/tag/syntax/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Sat, 13 Oct 2018 03:27:57 +0000 Installing CheckStyle plugin for Eclipse http://meng6net.localhost/blog/Installing_CheckStyle_plugin_for_Eclipse/ http://meng6net.localhost/blog/Installing_CheckStyle_plugin_for_Eclipse/ eclipse java syntax tool Tue, 16 May 2017 23:59:39 +0000 2018-10-13T03:27:57Z <p>I recently discovered a tool for checking Java code formatting and other coding style related issues -- <a href= "http://checkstyle.sourceforge.net/">CheckStyle</a>. It features <a href="http://checkstyle.sourceforge.net/availablechecks.html">a list of style checks</a> such as</p> <blockquote> <p>...<br /> * Restricts nested boolean operators (&amp;&amp;, ||, &amp;, | and ^) to a specified depth (default = 3).<br /> * Checks for empty blocks.<br /> * Checks for long source files.<br /> ...</p> </blockquote> <p>There's also an Eclipse plugin for it: https://checkstyle.org/eclipse-cs/#!/. The Eclispe update URL is http://eclipse-cs.sf.net/update/. As of at least Eclipse 4.8.0 (Aug., 2018), this update URL no longer works.</p> <p>There is a caveat at the time I install it:</p> <p>the plugin's homepage http://eclipse-cs.sourceforge.net/ gives http://sevntu-checkstyle.github.com/sevntu.checkstyle/update-site/ as the installation URL, but it does not work. However on http://eclipse-cs.sourceforge.net/downloads.html a different installation URL http://eclipse-cs.sf.net/update/ is given, which turns out to work correctly. It seems someone has not updated the Web pages consistently. And it has certainly confused some: http://stackoverflow.com/questions/11865025/error-while-installing-check-style-plugin-for-eclipse.</p> /blog/Installing_CheckStyle_plugin_for_Eclipse/#comments MathJax rendering test http://meng6net.localhost/test/mathjax_rendering_test/ http://meng6net.localhost/test/mathjax_rendering_test/ mathjax syntax test Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <p>Testing math content rendering with MathJax. Test cases are originally copy from <a href= "http://wiki.math.cmu.edu/iki/wiki/tips/20130930-ikiwiki/030-latex-differences/tests.html"> Gautam Iyer's test cases</a>, and then gradually modified and suplemented.</p> <h2>Inline math</h2> <p>This is an equation: $E = m c<sup>2</sup>$.</p> <h2>Theorem</h2> <p><strong>Theorem</strong> <em>(Mean Value Property).</em> Let $\Omega \subset \mathbb{R}^3$ be a domain, and $u$ is harmonic in $\Omega$ (i.e. $u = 0$ in $\Omega$). Suppose $B$ is a ball of radius $R$ and center $x_0$ that is completely contained in $\Omega$. Then $$ u(x_0) = \frac{1}{4 \pi R<sup>2</sup>} \int_{\partial B} u \, dS $$</p> <h2>Characters</h2> <h3>Subscripts</h3> <p>Subscripts: ${{a} <em>{1}}^{{b}</em> {1}}$</p> <h3>Curly braces</h3> <p>The curly brace is a special character in LaTeX. Therefore, to display it, it needs to be escaped by a backslash. The backslash that is not part of the original LaTeX keyword such as <code>\right</code> needs to be escaped. So, at the end you need <code>\\}</code> to display a closing curly brace:</p> <p><code>\left \\{X_1, X_2, \cdots, X_N \right \\}</code> displays as $\left \{X_1, X_2, \cdots, X_N \right \}$.</p> <h2>Multi-line equations</h2> <p>$$ \begin{equation} \label{eq1} \begin{split} A &amp; = \frac{\pi r<sup>2</sup>}{2} \\ &amp; = \frac{1}{2} \pi r<sup>2</sup> \end{split} \end{equation} $$</p> <p>$$ \begin{align<em>} 2x - 5y &amp;= 8 \\ 3x + 9y &amp;= -12 \end{align</em>} $$</p> <p>$$ \begin{align<em>} x&amp;=y &amp; w &amp;=z &amp; a&amp;=b+c\\ 2x&amp;=-y &amp; 3w&amp;=\frac{1}{2}z &amp; a&amp;=b\\ -4 + 5x&amp;=2+y &amp; w+2&amp;=-1+w &amp; ab&amp;=cb \end{align</em>} $$</p> <h2>Rotational Symmetry of the Laplacian</h2> <p>Let $T:\Real<sup>2</sup> \to \Real<sup>2</sup>$ be a rotation, and $u$ be any function. Then $$ \Laplace (u \circ T) = (\Laplace u) \circ T $$ This is also true in higher dimensions.</p> <p>Given that the Laplacian has this rotational symmetry, one might expect a nice cancellation / compact formula for the Laplacian in polar coordinates. We try this next.</p> <h2>The Laplacian in Polar Coordinates</h2> <p>Let $\hat x$, $\hat y$ be the unit vectors in the $x$ and $y$ direction respectively, and let $\hat r$ and $\hat \theta$ be the unit vectors in the $r$ and $\theta$ direction respectively. Explicitly, $$ \hat x = \begin{pmatrix}1\cr 0\end{pmatrix},\quad \hat y = \begin{pmatrix}0\cr1\end{pmatrix},\quad \hat r = \frac{1}{r}\begin{pmatrix}x\cr y\end{pmatrix},\quad \hat \theta = \frac{1}{r}\begin{pmatrix}-y\cr x\end{pmatrix}. $$</p> <p>First we compute that $$ \Grad u = \partial_x u \hat x + \partial_y u \hat y = \partial_r u \hat r + \frac{1}{r} \partial<em>\theta u \hat \theta. $$ Now we compute $$ \Laplace u = \Div \Grad u = (\Grad \partial_r u) \cdot \hat r + \partial_r u (\Div \hat r) + (\Grad \frac{1}{r} \partial</em>\theta u) \cdot \hat \theta + 0 = \partial_r<sup>2</sup> u + \partial_r u (\Div \hat r) + \frac{1}{r<sup>2</sup>} \partial_\theta<sup>2</sup> u. $$</p> <p>To finish the calculation, we only need to compute $\Div \hat r$. We do this as follows $$ \Div \hat r = \Div \left( \frac{1}{r} \begin{pmatrix} x \cr y \end{pmatrix} \right) = \frac{2}{r} + \Grad\left( \frac{1}{r} \right) \cdot \begin{pmatrix} x \cr y \end{pmatrix} = \frac{2}{r} - \frac{1}{r} = \frac{1}{r}. $$ Substituting back gives $$ \Laplace u = \partial_r<sup>2</sup> u + \frac{1}{r} \partial_r u + \frac{1}{r<sup>2</sup>} \partial_\theta<sup>2</sup> u. $$</p> <h1>Basic tests to check interference with markdown.</h1> <h2>Sub and super scripts.</h2> <p>Here's a superscript without math: a<sup>b</sup>, a_b. Here they are with math:</p> <ol> <li> <p>One backslash: ( a<sup>b</sup>, a_b ).</p> </li> <li> <p>Two backslashes: \( a<sup>b</sup>, a_b \).</p> </li> <li> <p>Three backslashes: \( a<sup>b</sup>, a_b \).</p> </li> </ol> <h2>Smileys</h2> <p><code>{x}</code> produces <img src="http://meng6net.localhost/smileys/star_on.png" alt="{x}" /> in normal mode. <strong>In math mode it will mess things up!</strong> However, smileys need whitespace before and after to be recognized. So while <code>$ {x} $</code> will mess things up, <code>${x}$</code> will be OK and produce ${x}$.</p> <h2>Checking if * and _ mess up math</h2> <p>The code</p> <pre><code>$$ a * b + b * c \qquad a_b + b_c, \qquad a^{b + c} $$ </code></pre> <p>produces $$ a * b + b * c \qquad a_b + b_c, \qquad a^{b + c} $$</p> <h1>MathJAX equation reference test</h1> <p>Here is a labeled equation: \begin{equation}x+1\over\sqrt{1-x<sup>2</sup>}\label{ref1}\end{equation} with a reference to ref1: \ref{ref1}, and another numbered one with no label: $$x+1\over\sqrt{1-x<sup>2</sup>}$$ This one uses \nonumber: \begin{equation}x+1\over\sqrt{1-x<sup>2</sup>}\nonumber\end{equation}</p> <p>Here's one using the equation environment: \begin{equation} x+1\over\sqrt{1-x<sup>2</sup>} \end{equation} and one with equation <em>environment: \begin{equation</em>} x+1\over\sqrt{1-x<sup>2</sup>} \end{equation*}</p> <p>This is a forward reference [\ref{ref2}] and another \eqref{ref2} for the following equation: \begin{equation}x+1\over\sqrt{1-x<sup>2</sup>}\label{ref2}\end{equation} More math: $$x+1\over\sqrt{1-x<sup>2</sup>}$$ Here is a ref inside math: (\ref{ref2}+1) and text after it.</p> <p>\begin{align} x&amp; = y_1-y_2+y_3-y_5+y_8-\dots &amp;&amp; \text{by \eqref{ref1}}\cr &amp; = y'\circ y^* &amp;&amp; \text{(by \eqref{ref3})}\cr &amp; = y(0) y' &amp;&amp; \text {by Axiom 1.} \end{align}</p> <p>Here's a bad ref [\ref{ref4}] to a nonexistent label.</p> <p>An alignment: \begin{align} a&amp;=b\label{ref3}\cr &amp;=c+d \end{align} and a starred one: \begin{align<em>} a&amp;=b\cr &amp;=c+d \end{align</em>}</p> <h1>Custom macro tests</h1> <p>This tests some of my predefined macros.</p> <h2>Inequalities</h2> <p>$$ a &lt; b, \quad a \leq b \quad a \geq b \quad a &gt; b. $$</p> <h2>Limits</h2> <p>Inline limits: $\displaystyle \lim <em>{x \to a} \frac{1}{x}$, $\displaystyle \max</em> {0, 1}$.</p> <p>Displayed <code>\displaystyle {\operatorname{ess} \sup} _{x \in \Real}</code> produces $$ \displaystyle {\operatorname{ess} \sup} _{x \in \Real} $$</p> <h2>Topics</h2> <h3>Subscript <code>_{xxx}</code> needs to be escaped <code>\_{xxx}</code></h3> <p>Since pairs of <code>_</code> denotes emphasis in Markdown syntax, it needs to be escaped:</p> <pre><code>$$ \begin{align} \hat\sigma^2\_\mathrm{N} &amp;= \frac{1}{N} \sum\_{i=1}^N \left( X\_i - \bar{X}\_N \right)^2 \\\\ &amp;= \frac{1}{N} \sum\_{i=1}^N \left( X\_i^2 - \bar{X}\_N^2 \right)~, \end{align} $$ </code></pre> <p>$$ \begin{align} \hat\sigma<sup>2</sup>_\mathrm{N} &amp;= \frac{1}{N} \sum_{i=1}^N \left( X_i - \bar{X}_N \right)<sup>2</sup> \\ &amp;= \frac{1}{N} \sum_{i=1}^N \left( X_i<sup>2</sup> - \bar{X}_N<sup>2</sup> \right)~, \end{align} $$</p> <p>Or, use a white space in front of <code>_</code>:</p> <pre><code>$$ \begin{align} \hat\sigma^2\_\mathrm{N} &amp;= \frac{1}{N} \sum\_{i=1}^N \left( X\_i - \bar{X}\_N \right)^2 \\\\ &amp;= \frac{1}{N} \sum\_{i=1}^N \left( X\_i^2 - \bar{X}\_N^2 \right)~, \end{align} $$ </code></pre> <p>$$ \begin{align} \hat\sigma<sup>2</sup> <em>\mathrm{N} &amp;= \frac{1}{N} \sum</em> {i=1}^N \left( X <em>i - \bar{X}</em> N \right)<sup>2</sup> \\ &amp;= \frac{1}{N} \sum <em>{i=1}^N \left( X</em> i<sup>2</sup> - \bar{X} _N<sup>2</sup> \right)~, \end{align} $$</p>