GreyMamba

Thinking Allowed … (under construction)

Thinking Allowed … (under construction)

A computer once beat me at chess, but it was no match for me at kick boxing.
Emo Philips
Snippets covering IT techniques, Python coding and Rapidweaver
Just a section to cover anything related to 'Information Technology'. Computers, Coding, Algorithms, A.I. and so on. There will probably be quite a bit on how to make a web site (one of the reasons I'm actually doing this is to learn how) including much on Rapidweaver and Stacks. There will be code - most likely Python along with general computery items.

I'm quite into Python programming and as such I've written a bit of an interactive Python booklet (link opens in new window) covering some of the stuff needed to program in it.

It's probably appropriate to mention here that I've used RapidWeaver 8 to help me generate this website. I've also made use of the excellent Free DNS service to overcome the limitations imposed by not having a static IP address.

MathJax - how to get equations onto the Web

Before I could start putting anything vaguely technical into the SciTech section it seemed to me that I needed to be able to display reasonably high quality equations in the pages. I coukld have used an equation editor in LibreOffice, Word or other bits of software and then cut and pasted a resultant image but this is a bit clunky and not entirely satisfactory. After the requisit faffing about and Google twiddling I found MathJax. This is a great system that allows you to embed Latex codes into your page and then renders this on-the-fly when the page is displayed. It works and it's free! To quote directly off their website :

MathJax allows you to include mathematics in your web pages, either using LaTeX, MathML, or AsciiMath notation, and the mathematics will be processed using JavaScript to produce HTML, SVG or MathML equations for viewing in any modern browser.

Essentially you can embed Latex code between $$ (or \[ and \] or \( and \))1 in your page and add a bit of magic pixie dust into the page Head. Then, when the page is displayed a call is made to a MathJax 'Content Distribution Network' (CDN) server which renders this code an returns a beautifully formed equation. As of toaday (11 May 2017) this is the magic code:

<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

Cloudfare, bless them, provide a 'CDN' server which does the heavy lifting.

So, now including something like $$x = {-b \pm {\sqrt{b^2-4ac} \over 2a}}$$ gives:

\[x = {-b \pm {\sqrt{b^2-4ac} \over 2a}}\]

Brilliant!

Have a look at the Latex post for some more information on Latex and some of the more useful codes.

\begin{equation}\tag{D23} E = mc^2 \end{equation}

\begin{equation}\tag{44} E = mc^2 \end{equation}

_1: $$ and \( works for a 'text' stack but you actually need '\\[and \\] if you're using a markdown stack in Rapidweaver.

You can also use more sophisticated LaTeX/TeX constructs. For instance, to display Maxwell's equations and to align the equations on the 'nablas' and have them numbered, do something like:

\begin{align}
\nabla & \cdot \vec{E} & = \frac{\rho}{\epsilon_0} \\
\nabla & \cdot \vec{B} & = 0 \\
\nabla & \times \vec{E}  & = - \frac{\delta \vec{B}}{\delta t} \\
\nabla & \times \vec{B}  & = \mu_0 \vec {J} +  \frac{1} {c^2 } \frac{\delta \vec{E}}{\delta t}
\end{align}

to get:

\[ \begin{align} \nabla & \cdot \vec{E} = \frac{\rho}{\epsilon_0} \\ \nabla & \cdot \overset{\mbox{→}}{B} = 0 \\ \nabla & \times \vec{E} = - \frac{\partial \vec{B}}{\partial t} \\ \nabla & \times \vec{B} = \mu_0 \vec {J} + \frac{1} {c^2 } \frac{\partial \vec{E}}{\partial t} \end{align} \]

Back

Nice photo from an unusual perspective. Kudos to Joshua Sortino

RapidWeaver Icon

Made in RapidWeaver