Programming in Mathematical Notation

This is a simple function call

Simple Example

The input file for a simple function, f(x) = x + 2

<?xml version="1.0"?>

<p>Example of a function</p>
<!-- should be f(x) = x + 2 -->
  <declare type="fn">

The "program" and "comment" tags are not MathML.

The "program" tag encloses the whole file to make it well-formed XML.

Everything inside the "comment" tag is copied to the xhtml output file. Consequently the comments can include HTML markup, and could even include images or diagrams (in SVG format). This part feels similar to some of the aims of literate programming.

The text output is simply f(x) = x + 2

The output in MathML presentation form is

Example of a function

f x = x + 2

Finally, the C++ output is

double f(double x){
    return x + 2;

Previous page: Introduction

Next page: An example using the trapezoidal rule to approximate an integral.

Written by Mark Dewing on July 20, 2005. Last updated on September 21, 2005.