<article xmlns:monet='http://monet.nag.co.uk/monet/ns' xmlns:x="jelly:xml" >
<title>OpenMath and MONET</title>
<subtitle>differentiation</subtitle>
<para>
<x:parse var="formula">
<OMOBJ>
<OMA>
<OMS cd='transc1' name='cos'/>
<OMA>
<OMS cd='arith1' name='power'/>
<OMV name='x'/>
<OMI>2</OMI>
</OMA>
</OMA>
</OMOBJ>
</x:parse>
The derivative of
<x:copyOf select="$formula/*"/>
is
<monet:query>
<monet:classification>
<monet:directive-type href='http://mathdox.org/phrasebook/maxima#eval'/>
</monet:classification>
<monet:body>
<monet:output>
<OMA>
<OMS cd='calculus1' name='diff'/>
<OMBIND>
<OMS cd='fns1' name='lambda'/>
<OMBVAR>
<OMV name='x'/>
</OMBVAR>
<x:copyOf select="$formula/OMOBJ/*"/>
</OMBIND>
</OMA>
</monet:output>
</monet:body>
</monet:query>
</para>
</article>
See the example running (only if the maxima service is set up properly).
The expression \cos(x^2) we saw
earlier, has now been inserted into a Jelly
variable that is able to contain XML.
Inserting XML-code into a Jelly variable
needs some parsing.
This is done by the <x:parse> tag.
The aim is to reuse the
XML stored in the variable as XML again instead of a value as in previous
examples. To this end the XML-contents of the variable needs to be copied from the
variable and into the XML structure of the document. This is done by means of
the <x:copyOf> tag. In this way one and the same expression can be printed
to the screen now and be used for calculations later as it will be used as input
for the MONET query. This MONET query adds some more OpenMath around the
contents of the XML-containing variable to tell a CAS to differentiate the
function x \mapsto \cos(x^2). The result is then printed to the screen as
well.