Monet

Queries to mathematical services are done using Monet. We give some examples.

Example 1. 

We start with an example calling the Maxima phrasebook. In this example we specify both in and output of the query using the native Maxima syntax.


<monet:query>
  <monet:classification>
    <monet:directive-type href='http://mathdox.org/phrasebook/maxima#eval_native_native'/>
  </monet:classification>
  <monet:body>
    <monet:output>2+3</monet:output>
  </monet:body>
</monet:query>

See the example running (only if the maxima service is set up properly).


Example 2. 

In this example we also call the Maxima phrasebook. However now we use the default setting of the phrasebook, implying that we use both for in and output OpenMath Syntax.


<monet:query>
  <monet:classification>
    <monet:directive-type href='http://mathdox.org/phrasebook/maxima#eval'/>
  </monet:classification>
  <monet:body>
    <monet:output>
      <OMOBJ>
        <OMA>
          <OMS name="plus" cd="arith1"/>
          <OMI>5</OMI>
          <OMI>7</OMI>
         </OMA>
      </OMOBJ>
    </monet:output>
  </monet:body>
</monet:query>

See the example running (only if the maxima service is set up properly).


The next example uses OpenMath, Jelly code, and a MONET expression.

Example 3. 


<article xmlns:monet='http://monet.nag.co.uk/monet/ns' xmlns:x="jelly:xml" >
  <title>OpenMath and MONET</title>
  <subtitle>differentiate</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.


We finish this section with an example of a query to Geogebra, a Java application for dynamic geometry.

Example 4. 

This is an example to start an applet with a prescribed input file.

        
<monet:query>
  <monet:classification>
    <monet:directive-type
      href="http://mathdox.org/phrasebook/geogebra#show"
    />
  </monet:classification>
  <monet:body>
    <monet:output>
      <attribute name="height" value="400"/>
      <attribute name="width" value="400"/>
      <attribute name="name" value="ggbApplet1"/>
      <xhtml:param name="filename" value="geogebra/voorbeeld-bb13-1.ggb"/>
      <xhtml:param name="framePossible" value="false"/>
    </monet:output>
  </monet:body>
</monet:query>
        
      

Sorry the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and activated. (click here to install Java now)


Example 5.  This is an example to start an applet and modify it during the start with JavaScript.

        
<monet:query>
  <monet:classification>
    <monet:directive-type
      href="http://mathdox.org/phrasebook/geogebra#show"
    />
  </monet:classification>
  <monet:body>
    <monet:output>
      <attribute name="height" value="400"/>
      <attribute name="width" value="400"/>
      <attribute name="name" value="ggbApplet2"/>
      <xhtml:param name="filename" value="geogebra/voorbeeld-bb13-1.ggb"/>
      <xhtml:param name="framePossible" value="false"/>
      <xhtml:script type="text/javascript">
        var applet = document.ggbApplet2;
        applet.evalCommand("f(x)=(x-1)*(x+1)*x");
      </xhtml:script>
    </monet:output>
  </monet:body>
</monet:query>
        
      

Sorry the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and activated. (click here to install Java now)