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

Hi Peter,

What Daniel suggests is very much what I do while applying xslt transforms as just-in-time coding of math from mathml documents.

The xslt would recognize any 
<m:apply>
                <m:eq />
                <m:ci>k</m:ci>
                <m:cn>1.0</m:cn>
</m:apply>
as a field with getters and setters in the generated class.  Arrays treated the same way.  Also the final results could be gotten back the same way where a mathml document needs to return more than one argument to the engine's scope.

I've explored many different avenues and purposes of just-in-time coding.  Went so far as exploring specialized xslt engine combined with direct byte-code manipulation (http://asm.ow2.org/) or producing output in OpenCL (http://www.khronos.org/opencl/) format running them via JavaCl(http://code.google.com/p/javacl/) or the nvidia tool kit.

This approach you are looking at can actually simplify use of gpu's etc. because it is solving the immediate runtime needs rather than try to be generalized, solving everything for everybody like conventional precompiled code attempts to do.


I'd enjoy more discussion of applying content mathml is this area.


Roger (We've talked in the past about ANTLR parsers for quixote-qcdb)


________________________________
 From: Daniel Marques <dani@wiris.com>
To: Peter Murray-Rust <pm286@cam.ac.uk>; www-math@w3.org 
Sent: Thursday, March 15, 2012 6:01 AM
Subject: RE: Using content-MathML for computation and analysis in Science and Engineering
 

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 programing” paradigm. In case you want to follow a fully “functional 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 
 
 
From:peter.murray.rust@googlemail.com [mailto: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
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069

Received on Thursday, 15 March 2012 18:00:29 UTC