Formeln mit Math – Beispiele

Beispiele für Formeln mit MathML

Jeder MathML-Ausdruck besteht aus einer Folge von Elementen, die wie HTML in spitzen Klammern sitzen. Genauso wie Attribute in HTML das Rendern des Elements beeinflussen oder zusätzliche Informationen für den Browser liefern, hat MathML eigene Attribute. Von Formeln kann man nie genung haben, oder?

23-02-02 SITEMAP CSS HTML JS Basis JS Web Tutorial SVG

Einfache Formeln mit MathML

Alle MathML-Tags fallen in eine von drei Kategorien: Interface, Presentation oder Content.

Interface-Elemente (z.B. das math-Element selbst)
legen fest, wie der MathML-Ausdruck in andere XML-Dokumente eingebunden wird.
Presentation Elemente
codieren Informationen über die zweidimensionale Struktur des Ausdrucks. mrow, mfrac, msqrt and msub erzeugen eine Zeile, einen Bruch, eine Quadratwurzel und einen tiefgestellten Ausdruck.
Content Elemente
codieren Informationen über die logische Bedeutung des Ausdrucks. Plus- und Minuszeichen stehen für Addition / Subtraktion, das Gleichheitszeichen für die Anwendung einer Funktion.

Bezeichnungen, Operatoren und Zahlen werden von verschiedenen Elementen mit leicht voneinander abweichender Typografie (Schriften, Abstände). Variablen werden üblicherweise kursiv (italic) gerendert, Zahlen in einer normal gestellten Schrift. Um Operatoren liegt etwas mehr Abstand.

Einfache Formel mit Exponent

x 2 + 4 x + 4 = 0
Math Markup
<math style="display:block">	
<mrow>			
	<mrow>
		<msup>
			<mi>x</mi>
			<mn>2</mn>
		</msup>
		<mo>+</mo>
		<mrow>
			<mn>4</mn>
			<mo>⁢</mo>
			<mi>x</mi>
		</mrow>
		<mo>+</mo>
		<mn>4</mn>
	</mrow>
	<mo>=</mo>
	<mn>0</mn>
</mrow>
</math>

MathML Tabellen, Matrix

Klammern konnten früher mit mfended eingesetzt werden, aber mfenced gilt jetzt als veraltet und sollte nicht mehr benutzt werden. Anstelle von <mfenced open="[" close="]"> emuliert <mrow> mit <mo></mo> die Klammerung.

A= [ x y z w ]
Math Markup
<math>
	<mrow>
		<mi>A</mi><mo>=</mo>
		<mrow>
			<mo>[</mo>
				<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>
			<mo>]</mo>
		<mrow>
	</mrow>
</math>

Satz des Pythagoras

a2 + b2 = c2
Math Markup
<math style="display:block">	
<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>

Bedingungen

if x = y then a x = a y

Damit nach if ein Freiraum entsteht, helfen keine Leerzeichen: <mtext>if </mtext>. Leerzeichen werden vom MathML-Prozessor aus mi, mo, mn und mtext entfernt. Anstelle dessen wird ein mspace eingefügt.

width
Optionales Attribut für die Gesamtbreite des mspace-Elements
height
Optionales Attribut für die Gesamthöhe über der Grundlinie
depth
Optionales Attribut für die Gesamthöhe unter der Grundlinie

Angabe in: em, rem, ch, ex, px, in, cm, mm, pt, pc.

Math Markup
<math style="display:block">
<mrow>
	<mtext>if</mtext>
	<mspace depth="0.5ex" height="0.5ex" width="1ex"/>
	<mrow>
		<mi>x</mi>
		<mo>=</mo>
		<mi>y</mi>
	</mrow>
	<mspace depth="0.5ex" height="0.5ex" width="1ex"/>
	<mtext>then</mtext>
	<mspace depth="0.5ex" height="0.5ex" width="1ex"/>
	<mrow>
		<mrow>
			<mi>a</mi>
			<mi>x</mi>
		</mrow>
		<mo>=</mo>
		<mrow>
			<mi>a</mi>
			<mi>y</mi>
		</mrow>
	</mrow>
</mrow>
</math>

Brüche

x - 1 100
Math Markup
<math style="display:block">
<mfrac>
	<mrow>
		<mi>x</mi>
		<mo>-</mo>
		<mn>1</mn>
	</mrow>
	<mn>100</mn>
</mfrac>
</math>

Wurzel

x + y
Math Markup
<msqrt>
	<mi>x</mi>
	<mo>+</mo>
	<mi>y</mi>
</msqrt>
x 3
Math Markup
<mroot>
	<mi>x</mi>
	<mn>3</mn>
</mroot>

Integrale

-1 +1 d x x
Math Markup
<mrow>
	<munderover>
		<mo>∫</mo>
		<mn>-1</mn>
		<mn>+1</mn>
	</munderover>
	<mfrac>
		<mrow>
			<mi>d</mi>
			<mi>x</mi>
		</mrow>
		<mi>x</mi>
	</mfrac>
</mrow>
{ 2 x + y = 8 x + y = 6
Math Markup
<math style="display:block">
<mrow>
	<mo>{</mo>
	<mtable>
		<mtr>
			<mtd>
				<mrow>
					<mrow>
						<mrow>
							<mn>2</mn>
							<mo>⁢</mo>
							<mi>x</mi>
						</mrow>
						<mo>+</mo>
						<mi>y</mi>
					</mrow>
					<mo>=</mo>
					<mn>8</mn>
				</mrow>
			</mtd>
		</mtr>
		<mtr>
			<mtd>
				<mrow>
					<mrow>
						<mi>x</mi>
						<mo>+</mo>
						<mi>y</mi>
					</mrow>
					<mo>=</mo>
					<mn>6</mn>
				</mrow>
			</mtd>
		</mtr>
	</mtable>
</mrow>
</math>

Quadratische Polynome

x = - b ± b 2 - 4 a c 2 a
Math Markup
<mrow>
	<mi>x</mi>
	<mo>=</mo>
	<mfrac>
		<mrow>
			<mo form="prefix">-</mo>
			<mi>b</mi>
			<mo>±</mo>
			<msqrt>
				<msup>
					<mi>b</mi>
					<mn>2</mn>
				</msup>
				<mo>-</mo>
				<mn>4</mn>
				<mo>⋅</mo>
				<mi>a</mi>
				<mo>⋅</mo>
				<mi>c</mi>
			</msqrt>
		</mrow>
		<mrow>
			<mn>2</mn>
			<mo>⋅</mo>
			<mi>a</mi>
		</mrow>
	</mfrac>
</mrow>

Mathe-Sonderzeichen

&sdot;
Punktoperator, Punkt-Malzeichen
× &times;
Multiplikation, Kreuz-Malzeichen
&lowast;
Stern – Multiplikation
÷ &divide;
Geteilt durch, Division
&prod;
Produkt
± &plusmn;
Plusminus
&sum;
Summenzeichen
&infin;
Unendlich

Stile für Math

mathvariant
normal, bold, italic, monospace, double-struck …
mathsize
small, normal, big
mathcolor
#rgb, color-name
mathbackground
#rgb, color-name