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

From: Daniel Marques <dani@wiris.com>
Date: Thu, 15 Mar 2012 11:01:32 +0100
Message-ID: <1d94b2414ce1b97974de86814e384a7b@mail.gmail.com>
To: Peter Murray-Rust <pm286@cam.ac.uk>, www-math@w3.org
```Hi Peter,

With content MathML you can express mathematics in a semantic way. What it
seems you need is some kind of formalization of an algorism witch is
outside the scope of content MathML if you consider the “structured
programming” approach:

(k,req)à(R à k(R-reg)^2 )

or a logical approach:

k=0.1 /\ req=1.5 /\ (E=Ràk(R-reg)^2)

Whatever model you chose, content MathML can still be useful to express
some pieces of the whole system. For example, if you want to consider the
algorism as a sequence of declaration statements, the right part of each
statement can be encoded with content MathML. In your case, you would need
three statements:

k=*0.1*

req=*1.5*

E=*R **à** k(R-req)^2*

where only the right part of the statements is encoded as content MathML.

Daniel Marques

CTO at www.wiris.com

peter.murray.rust@googlemail.com] *On Behalf Of *Peter Murray-Rust
*Sent:* jueves, 15 de marzo de 2012 9:42
*To:* www-math@w3.org
*Subject:* Using content-MathML for computation and analysis in Science and
Engineering

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