MathML

jumentousmanlyInternet και Εφαρμογές Web

21 Οκτ 2013 (πριν από 3 χρόνια και 8 μήνες)

83 εμφανίσεις

Math
ML



Author: Jonathan Wong

Date: 04/12/2012


What is MathML?

MathML

(Mathematical Markup Language) is an application of XML and used to represent and
encode

the structure of mathematical expressions so that they can be displayed, manipulated and
shared over the World Wide Web.

MathML is a recommendation of the W3C math working group
and is projected to be the standard format for scientific publication on the
Web

In MathML, these two styles of encoding are called content encodings and presentation encodings.

MathML deals not only with the presentation but also the meaning of formula components (the latter
part of MathML is known as “Content MathML”).
For exampl
e, web pages with MathML embedded
in them can be viewed as normal web pages with many browsers, but visually impaired users can also
have the same MathML read to them through the use of screen readers.

Presentation MathML
:
focuses on the display of an equa
tion, and has about 30 elements (see
appendix)

Content MathML
:

focuses on the semantics, or meaning, of the ex
pression rather than its layout (see
appendix)


A short tutorial

How do we represent the formula:
a2 + b2 = c2 using MathML

The good thing about MathML is that integrates with HTML5. You Copy and paste the MathML code
below and view in a browser and see the result.
The recommended browser to test is Firefox.

<!doctype html>


<html>


<head>


<meta charset="UTF
-
8">


<title>P
ythagorean theorem</title>


</head>


<body>


<math xmlns="http://www.w3.org/1998/Math/MathML">


<mrow>


<msup><mi>a</mi><mn>2</mn></msup>


<mo>+</mo>


<msup><mi>b</mi><mn>2</mn></msup>


<mo>=</mo>


<msup><mi>c<
/mi><mn>2</mn></msup>


</mrow>


</math>


</body>

</html>


The above example is a very simple example and

could in fact be done without MathML

Here’s a more complex example:


<!doctype html>


<html>


<head>


<meta charset="UTF
-
8">


<title>Mat
hML Examples</title>


</head>


<body>


<math xmlns="http://www.w3.org/1998/Math/MathML">


<mrow>


<mi>A</mi>


<mo>=</mo>


<mfenced open="[" close="]">


<mtable>


<mtr>


<mtd
><mi>x</mi></mtd>


<mtd><mi>y</mi></mtd>


</mtr>


<mtr>


<mtd><mi>z</mi></mtd>


<mtd><mi>w</mi></mtd>


</mtr>


</mtable>


</mfenced>


</mrow>


</math>

</body>

</html>


Preview this in a
Firefox

browser and you get:



According to Wikipedia MathML
Web browsers

support:

Of the major web browsers, recent versions of Gecko browsers (e.g., Firefox and Camin
osupport
MathML natively.

W
hile the WebKit layout engine does have d
evelopment version of MathML,

this option is only
available in version 5.1 and higher of Safar
i, which is based on WebKit.

Pre
-
release builds of Chrome
on desktop platforms support MathML now. As Chrome on iOS uses
the Apple's WebKit
implementation, it supports MathML.

Internet Explorer does not support MathML natively. Support in IE7, IE8 and IE9 can be added by
installing the MathPlayer plugin


Using Editors to create MathML


It is unlikely you will want to hand code MathML. You will want to use an editor. I recommend using

W3C's Amaya browser
:

http://www.w3.org/Amaya/

Once installed, create a new formula document.



Then insert a formula




To view the MathML code for the
formula you just created, go to view and click on ‘Show Source’


You can insert this code in an HTML 5 page


Additional
Comments

The plan is that tutors us
e Amaya to construct their formulas which we can then insert into our html5
pages

The biggest issue
is that not all browser currently support MathML, and may require plugins.

We could resolve this issue by recommending browsers to use, i.e. we recommend the students use
Firefox on our course.

Over time MathML will be adopted by web browsers.



Appendix


Presentation Element Reference

This page lists the MathML 2.0 presentation markup elements. Each element links to reference
information about the MathML description of the element, with comments about the WebEQ 3
implementation.


Token Elements:

<mi>

ide
ntifier

<mn>

number

<mo>

operator, fence, or separator

<mtext>

text

<mspace/>

space

<ms>

string literal

<mglyph>

for using non
-
standard character glyphs (MathML 2.0)

General Layout:

<mrow>

group any number of subexpressions horizontally

<mfrac>

form a

fraction from two subexpressions

<msqrt>

form a square root sign (radical without an index)

<mroot>

form a radical with specified index

<mstyle>

style change

<merror>

enclose a syntax error message from a preprocessor

<mpadded>

adjust space around cont
ent

<mphantom>

make content invisible but preserve its size

<mfenced>

surround content with a pair of fences

<menclose>

enclose content with a stretching symbol such as a long division sign (MathML 2.0)

Scripts and Limits:

<msub>

attach a subscript to a

base

<msup>

attach a superscript to a base

<msubsup>

attach a subscript
-
superscript pair to a base

<munder>

attach an underscript to a base

<mover>

attach an overscript to a base

<munderover>

attach an underscript
-
overscript pair to a base

<mmultiscripts>

attach prescripts and tensor indices to a base

Tables:

<mtable>

table or matrix

<mtr>

row in a table or matrix

<mtd>

one entry in a table or matrix

<maligngroup/>

alignment group marker

<malignmark/>

alignment point marker

<mlabeledtr/>

row in a table o
r matrix with a label or equation number (MathML 2.0)

Actions:

<maction>

bind actions to a subexpression




Content Element Reference

This page lists the MathML 2.0 content markup elements. Each element links to reference information
about the MathML
description of the element, with comments about the WebEQ 3 implementation.

Token Elements:

<cn>

Content Number

<ci>

Content Identifier

<csymbol>

Publicly defined symbols, functions and constants (MathML 2.0)


Basic Content Elements:

<apply>

explicit appli
cation of a function to its argument

<reln>

equation or relation

<fn>

user
-
defined function

<interval>

interval constructor

<inverse/>

generic inverse

<sep/>

separator in numeric values

<condition>

domain constructor

<declare>

declaration

<lambda>

function

construction from an expression

<compose/>

compose two or more functions

<ident/>

identity function

<domain/>

domain of a function (MathML 2.0)

<codomain/>

codomain of a function (MathML 2.0)

<image/>

image of a function (MathML 2.0)

<domainofapplication/
>

region to integrate over, etc (MathML 2.0)

<piecewise/>

piecewise defined function (MathML 2.0)

<piece/>

one part of a piecewise function definition (MathML 2.0)

<otherwise/>

default case of a piecewise function definition(MathML 2.0)


Arithmetic,
Algebra and Logic:

<quotient/>

division modulo base

<exp/>

exponentiation

<factorial/>

factorial

<divide/>

division

<max/>

maximum

<min/>

minimum

<minus/>

subtraction

<plus/>

addition

<power/>

to the power of

<rem/>

remainder modulo base

<times/>

multiplic
ation

<root/>

nth root

<gcd/>

greatset common denominator

<and/>

boolean and

<or/>

boolean or

<xor/>

boolean exclusive or

<not/>

boolean not

<implies/>

boolean implies

<forall/>

universal quantifier

<exists/>

existential quantifier

<abs/>

absolute value

<c
onjugate/>

complex conjugate

<arg/>

argument of a complex number (MathML 2.0)

<real/>

real part of a complex number (MathML 2.0)

<imaginary/>

imaginary part of a complex number (MathML 2.0)

<lcm/>

least common multiple (MathML 2.0)

<floor/>

greatest
integer less than or equal to a real number (MathML 2.0)

<ceiling/>

least integer greater than or equal to a real number (MathML 2.0)


Relations:

<eq/>

equal

<neq/>

not equal

<gt/>

greater than

<lt/>

less than

<geq/>

greater than or equal

<leq/>

less than
or equal

<equivalent/>

logically equivalent (MathML 2.0)

<approx/>

approximately equal (MathML 2.0)

<factorof/>

the "divides" operator (MathML 2.0)

Calculus:

<int/>

integral

<diff/>

derivative, differentiatiom

<partialdiff/>

partial derivative

<lowlimit>

l
ower limit (of integral, sum etc.)

<uplimit>

upper limit (of integral, sum etc.)

<bvar>

bound variable (e.g. for integral)

<degree>

holds the n in "nth derivative"

<divergence>

divergence differential operator (MathML 2.0)

<gradient>

gradient differential
operator (MathML 2.0)

<curl>

curl differential operator (MathML 2.0)

<laplacian>

Laplacian differential operator (MathML 2.0)

Theory of Sets:

<set>


<list>


<union/>

union or meet

<intersect/>

intersection or join

<in/>

is in, is a member

<notin/>

is not
in, is not a member

<subset/>

is a subset

<prsubset/>

is a proper subset

<notsubset/>

is not a subset

<notprsubset/>

is not a proper subset

<setdiff/>

set difference

<card/>

cardinality of a set (MathML 2.0)

<cartesianproduct/>

form the Cartesian product o
f two sets (MathML 2.0)


Sequences and Series:

<sum/>

sum terms of a sequence

<product/>

multiply terms in a sequence

<limit/>

limiting value of a sequence

<tendsto/>

relation on sequences


Elementary Classical Functions:


<exp/>

exponential function
(MathML 2.0)

<ln/>

natural logarithm

<log/>

logarithm to given base

<logbase>

base of the logarithm

<sin/>

trig function

<cos/>

trig function

<tan/>

trig function

<sec/>

trig function

<csc/>

trig function

<cot/>

trig function

<sinh/>

hyperbolic trig
function

<cosh/>

hyperbolic trig function

<tanh/>

hyperbolic trig function

<sech/>

hyperbolic trig function

<csch/>

hyperbolic trig function

<coth/>

hyperbolic trig function

<arcsin/>

inverse trig function

<arccos/>

inverse trig function

<arctan/>

inverse
trig function

<arccot/>

inverse trig function (MathML 2.0)

<arccsc/>

inverse trig function (MathML 2.0)

<arcsec/>

inverse trig function (MathML 2.0)

<arccosh/>

inverse hyperbolic trig function (MathML 2.0)

<arccoth/>

inverse hyperbolic trig function (MathM
L 2.0)

<arccsch/>

inverse hyperbolic trig function (MathML 2.0)

<arcsech/>

inverse hyperbolic trig function (MathML 2.0)

<arcsinh/>

inverse hyperbolic trig function (MathML 2.0)

<arctanh/>

inverse hyperbolic trig function (MathML 2.0)


Statistics:

<mean/>

mean or average

<sdev/>

standard deviation

<variance/>

variance

<median/>

median

<mode/>

mode

<moment/>

moment

<momentabout/>

moment about a point (MathML 2.0)


Linear Algebra:

<vector>

vector

<matrix>

matrix

<matrixrow>

matrix row

<determinant/>

determina
nt

<transpose/>

transpose

<selector/>

select a matrix row or entry

<vectorproduct/>

vector product (MathML 2.0)

<scalarproduct/>

scalar product (MathML 2.0)

<outerproduct/>

outer product (MathML 2.0)

Semantic Mapping Elements:

<annotation>


<semantics>


<a
nnotation
-
xml>



Constant and Symbol Elements:

<integers>

set of integers (MathML 2.0)

<reals>

set of real numbers (MathML 2.0)

<rationals>

set of rational numbers (MathML 2.0)

<naturalnumbers>

set of natural numbers (MathML 2.0)

<complexes>

set of complex

numbers (MathML 2.0)

<primes>

set of prime integers (MathML 2.0)

<exponentiale>

base for natural logarithms, approx. 2.7183 (MathML 2.0)

<imaginaryi>

square root of
-
1 (MathML 2.0)

<notanumber>

placeholder for an ill
-
defined floating point operation (Math
ML 2.0)

<true>

boolean constant (MathML 2.0)

<false>

boolean constant (MathML 2.0)

<emptyset>

the empty set (MathML 2.0)

<pi>

Ratio of circumference to diameter for a circle, approx. 3.1416 (MathML 2.0)

<eulergamma>

Euler's constant, approx. 0.5772 (MathML

2.0)

<infinity>

Infinity (MathML 2.0)