# Using content-MathML for computation and analysis in Science and Engineering

From: Peter Murray-Rust <pm286@cam.ac.uk>
Date: Thu, 15 Mar 2012 08:41:38 +0000

```I hope this is the right list for my topic.

I am building a semantic system for physical science (primarily chemistry
at the moment), based on XML and want to embed content-MathML to support
equations, and computation. I haven't been able to find good examples of
this and if they exist I'd appreciate pointers. If not I'd like to discuss
my requirements on this list.

As a typical example, the energy of a bonded pair of atoms in a molecule
can be expressed as a quadratic relationship relating the Energy (E) to the
distance (r):
E = k(R-req)^2
Here k and req are constants that depend on the atoms.
and in MathML I can write this as a lambda expression

<m:math xmlns:m='http://www.w3.org/1998/Math/MathML'>
<m:lambda>
<m:bvar>
<ci>R</ci>
</m:bvar>
<m:ci>
<m:apply>
<m:times />
<m:ci>k</m:ci>
<m:apply>
<m:power/>
<m:apply>
<m:minus />
<m:ci>R</m:ci>
<m:ci>req</m:ci>
</m:apply>
<m:cn>2</m:cn>
</m:apply>
</m:apply>
</m:ci>
</m:lambda>
</m:math>

This describes how the (anonymous) energy varies as a function of R.
Although k and req are "constants", they vary with different types of atoms
so shouldn't be hardcoded as numbers (cn).

I have built a computation engine that is able to manipulate this MathML
but I am unclear of the right way to bind it. How, for example, do I add
the semantics:
k = 0.1,
req=1.5

and get them substituted in the equation? can I write the whole problem
(including the algorithm) in MathML? Is there a convention or does everyone
hack their own?

I now see content-MathML as having immense power for declarative
programming in this area. It will raise the quality of code, allow
validation, allow parallelisation and other optimisation, and also make
algorithms more accessible to users. It also allows symbol manipulation
(e.g. we often want analytical derivatives).

P.

--
Peter Murray-Rust