Snippet: Plot format in Wolfram

This snippet demonstrates the polt format that I often used in Wolfram Mathematica.

Plot[Sin[x], {x, -Pi, Pi}, 
     Mesh->None, PlotRange->{{-Pi, Pi}, {-2, 2}}, 
     AspectRatio->9/16, PlotTheme->"Scientific", FrameStyle->Black, 
     TicksStyle->Directive[FontSize->20], ImageSize->Large,
     AxesLabel->Automatic, LabelStyle->Directive[FontSize->20,
     FontFamily->"Times New Roman"], Epilog->{Text[Style[
     ToExpression[ "y = 12 \\frac{\\partial^2 f(x)}{\\partial x^2}", 
     TeXForm, HoldForm], FontFamily->"Times New Roman", FontSize->20, 
     Bold, Black], Scaled[{.25, .80}]]}]

Here is the diagram,

Here is the Wolfram notebook (Ua98n5.nb) used in this post.

Snippet: Matrix with Euler angles

This snippet posts an Excel to calculate the matrix with Euler angles. To describe the rotation of a crystal frame, commonly, we use three angles: $ \alpha$, $ \beta$, and $ \gamma$. They are also known as Bunge angles.

The matrix to rotate the crystal frame in reference frame is described by Euler angles as below:

$$ \displaystyle \mathbf{B}=\begin{bmatrix}
\cos(\alpha)\cos(\gamma) \\
– \sin(\alpha)\sin(\gamma)\cos(\beta)
\sin(\alpha)\cos(\gamma) \\
-\cos(\alpha)\sin(\gamma) \\
– \sin(\alpha)\cos(\gamma)\cos(\beta)
-\sin(\alpha)\sin(\gamma) \\
+ \cos(\alpha)\cos(\gamma)\cos(\beta)
\end{matrix}& \cos(\gamma)\sin(\beta)\\
\sin(\alpha)\sin(\beta) & -\cos(\alpha)\sin(\beta) & \cos(\beta)
\end{bmatrix} $$

In this Excel (Cf06b0.xlsx), you just need to input three Euler angles and the vector in reference frame. It will give the matrix and the inverse matrix with these three Euler angles. Also, it will give the vector in crystal frame.


This snippet is very useful for debugging the code with the rotation of Euler angles.