Skip to content

Commit aaa984e

Browse files
committed
Add a latex sample to demo
1 parent c16ca98 commit aaa984e

File tree

2 files changed

+111
-1
lines changed

2 files changed

+111
-1
lines changed

demo/eulers-identity.latex.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Euler’s identity
2+
3+
In mathematics, **Euler’s identity** (also known as _Euler’s
4+
equation_) is the equality
5+
6+
$$ e^{i\pi} + 1 = 0 $$
7+
8+
where
9+
10+
- $e$ is Euler's number, the base of natural logarithms,
11+
- $i$ is the imaginary unit, which by definition satisfies $i^2 = -1$,
12+
and
13+
- $\pi$ is pi, the ratio of the circumference of a circle to its
14+
diameter.
15+
16+
Euler’s identity is named after the Swiss mathematician Leonhard
17+
Euler. It is a special case of Euler’s formula $e^{ix} = \cos x +
18+
i\sin x$ when evaluated for $x=\pi$. Euler's identity is considered an
19+
exemplar of mathematical beauty, as it shows a profound connection
20+
between the most fundamental numbers in mathematics. In addition, it
21+
is directly used in a proof that $\pi$ is transcendental, which
22+
implies the impossibility of squaring the circle.
23+
24+
## Imaginary exponents
25+
26+
Euler’s identity asserts that $e^{i\pi}$ is equal to $-1$. The
27+
expression $e^{i}$ is a special case of the expression $e^z$, where
28+
$z$ is any complex number. In general, $e^z$ is defined for complex
29+
$z$ by extending one of the definitions of the exponential function
30+
from real exponents to complex exponents. For example, one common
31+
definition is:
32+
33+
$$
34+
e^z = \lim_{n\to\infty} \left(1 + \frac{z}{n}\right)^n.
35+
$$
36+
37+
Euler’s identity therefore states that the limit, as $n$ approaches
38+
infinity, of $\left(1 + \frac{i \pi}{n}\right)^n$ is equal to $-1$.
39+
40+
Euler’s identity is a special case of Euler’s formula, which states
41+
that for any real number $x$,
42+
43+
$$ e^{ix} = \cos x + i\sin x $$
44+
45+
where the inputs of the trigonometric functions sine and cosine are
46+
given in radians.
47+
48+
![Euler's formula for a general angle](https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Euler%27s_formula.svg/330px-Euler%27s_formula.svg.png)
49+
50+
In particular, when $x = \pi$,
51+
52+
$$
53+
e^{i\pi} = \cos \pi + i \sin \pi.
54+
$$
55+
56+
Since
57+
$$ \cos \pi = -1 $$
58+
and
59+
$$ \sin \pi = 0 $$
60+
61+
it follows that
62+
$$ e^{i\pi} = -1 + 0i, $$
63+
64+
which yields Euler's identity:
65+
66+
$$ e^{i\pi} + 1 = 0. $$
67+
68+
## Generalizations
69+
70+
Euler’s identity is also a special case of the more general identity
71+
that the $n$th roots of unity, for $n > 1$, add up to $0$:
72+
73+
$$
74+
\sum_{k=0}^{n-1} e^{2\pi i\frac{k}{n}} = 0 .
75+
$$
76+
77+
Euler’s identity is the case where $n = 2$.
78+
79+
A similar identity also applies to quaternion exponential: let $\left\{i, j,
80+
k\right\}$ be the basis quaternions; then,
81+
82+
$$
83+
e^{\frac{1}{\sqrt{3}} (i \pm j \pm k) \pi} + 1 = 0 .
84+
$$
85+
86+
More generally, let q be a quaternion with a zero real part and a norm
87+
equal to $1$; that is, $q = ai + bj + ck$, with $a^2 + b^2 + c^2 =
88+
1$. Then one has
89+
90+
$$
91+
e^{q \pi} + 1 = 0 .
92+
$$
93+
94+
The same formula applies to octonions, with a zero real part and a
95+
norm equal to $1$. These formulas are a direct generalization of
96+
Euler’s identity, since $i$ and $-i$ are the only complex numbers with
97+
a zero real part and a norm (absolute value) equal to $1$.

demo/main.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ if (
3737
throw new Error("playground not in DOM");
3838
}
3939

40+
{
41+
const { searchParams } = new URL(window.location.href);
42+
43+
if (searchParams.has("latex")) {
44+
rendererControl.value = "temml";
45+
}
46+
}
47+
4048
let renderer = rendererControl.value === "temml" ? "temml" : "mathml";
4149

4250
/**
@@ -222,7 +230,12 @@ blockDelimitersInput.addEventListener("change", handleBlockDelimitersChange);
222230
handleBlockDelimitersChange();
223231

224232
if (!textInput.value) {
225-
fetch("./eulers-identity.md")
233+
const startDocPath =
234+
rendererControl.value === "temml"
235+
? "./eulers-identity.latex.md"
236+
: "./eulers-identity.md";
237+
238+
fetch(startDocPath)
226239
.then((r) => r.text())
227240
.then((text) => {
228241
textInput.value = text;

0 commit comments

Comments
 (0)