Zeno's Notes


Posts tagged math

14 notes

LaTeX pro tip: suppress line/equation numbers in math environments

My colleague had this question today, so I decided to do a quick post about it.


assigns a running (throughout the document or section of it) equation number to each line of the environment. Sometimes you want to suppress those numbers.


suppresses equation numbers for every line of the align environment. But what to do if you have a formula that stretches over several lines? You want to give a number to the formula, but only one. The solution is to use \notag. Here is an example:

  \min_{\mathbf{W},\mathbf{H},\mathbf{b^\text{U}}, \mathbf{b^\text{I}}}
  \sum_{(u, i, r_{u,i}) \in \mathcal{D}^\text{train}}
  & ( \sigma(\mu + b^\text{U}_u + b^\text{I}_i + \langle \mathbf{w_u}, \mathbf{h_i} \rangle) - r_{u,i} )^2   \notag \\
  & + \lambda_b (\| \mathbf{b^\text{U}} \|^2 + \| \mathbf{b^\text{I}} \|^2)                                         \\
  & + \lambda_u \| \mathbf{W} \|^2 + \lambda_i \| \mathbf{H} \|^2 ,                                          \notag

Here is how it looks in a complete paper.

Filed under latex math formula publishing

30 notes

TIL: The result of abs() is not always positive in Java

Just saw this in a blog post by Markus Weimer.

In Java, the result of abs(i) is negative if i equals Integer.MIN_VALUE. I never thought about that. On the other hand, I think (hope …) I never hit that corner case in any of my projects.

By the way, in C#, an OverflowException is thrown in such a case.

Filed under java csharp mono programming integer absolute math