Skip to content

Commit

Permalink
Some more math stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jakep-allenai committed Mar 6, 2025
1 parent 7f36ac8 commit 438e68e
Show file tree
Hide file tree
Showing 65 changed files with 620 additions and 989 deletions.
20 changes: 10 additions & 10 deletions olmocr/bench/katex/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ def render_equation(
eq_hash = get_equation_hash(equation, bg_color, text_color, font_size)
cache_dir = get_cache_dir()
cache_file = cache_dir / f"{eq_hash}.png"
cache_error_file = cache_dir / f"{eq_hash}_error"

# Check if the equation is already cached
if use_cache and cache_file.exists():
return Image.open(cache_file)
if use_cache:
if cache_error_file.exists():
return None

if cache_file.exists():
return Image.open(cache_file)

# We need to escape backslashes for JavaScript string
escaped_equation = equation.replace("\\", "\\\\")
Expand All @@ -86,9 +91,6 @@ def render_equation(
if not os.path.exists(katex_css_path) or not os.path.exists(katex_js_path):
raise FileNotFoundError(f"KaTeX files not found. Please ensure katex.min.css and katex.min.js are in {script_dir}")

# Temporary file to save the screenshot
temp_path = str(cache_file)

with sync_playwright() as p:
# Launch a headless browser
browser = p.chromium.launch()
Expand Down Expand Up @@ -155,9 +157,7 @@ def render_equation(

if has_error:
print(f"Error rendering equation: '{equation}'")
# Clean up any partially created cache file
if os.path.exists(temp_path):
os.remove(temp_path)
cache_error_file.touch()
browser.close()
return None

Expand All @@ -168,13 +168,13 @@ def render_equation(
container = page.query_selector("#equation-container")

# Take the screenshot
container.screenshot(path=temp_path)
container.screenshot(path=str(cache_file))

# Close the browser
browser.close()

# Return the image as a Pillow Image
return Image.open(temp_path)
return Image.open(cache_file)

def main():
# Example equation: Einstein's famous equation
Expand Down
30 changes: 30 additions & 0 deletions olmocr/bench/sample_data/chatgpt/mathfuncs_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

1. Euler's Identity

\[ e^{i\pi} + 1 = 0 \]

Connects five fundamental constants \((e, i, \pi, 1, 0)\), revealing the profound relationship between exponential functions and trigonometry.

2. Pythagorean Theorem

\[ a^2 + b^2 = c^2 \]

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

3. The Fundamental Theorem of Calculus

\[ \int_{a}^{b} f(x) \, dx = F(b) - F(a) \]

Establishes that differentiation and integration are inverse operations. If \( F \) is an antiderivative of \( f \), the definite integral equals \( F(b) - F(a) \). Revolutionized mathematical problem-solving.

4. Maxwell's Equations

\[ \nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0} \]
\[ \nabla \cdot \mathbf{B} = 0 \]
\[ \nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t} \]
\[ \nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \]

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
22 changes: 22 additions & 0 deletions olmocr/bench/sample_data/chatgpt45/mathfuncs_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

1. Euler's Identity
\[ e^{i\pi} + 1 = 0 \]
Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry.

2. Pythagorean Theorem
\[ a^2 + b^2 = c^2 \]
In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

3. The Fundamental Theorem of Calculus
\[ \int_{a}^{b} f(x)\,dx = F(b) - F(a) \]
Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problem-solving.

4. Maxwell's Equations
\[ \nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0} \]
\[ \nabla \cdot \mathbf{B} = 0 \]
\[ \nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t} \]
\[ \nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \]
Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
36 changes: 36 additions & 0 deletions olmocr/bench/sample_data/gotocr/mathfuncs_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Made with
The 20 Most Important Mathematical Equations
A journey through the most elegant and influential formulas in mathematics
1. Euler’s Identity
2. Pythagorean Theorem
e
iττ + 1 = 0
a2 + b2 = c2
3. The Fundamental Theorem of Calculus
4. Maxwell’s Equations
Establishes that differentiation and integration are inverse
operations. If F is an antiderivative of f, the definite integral
equals F(b) - F(a). Revolutionized mathematical problem-
solving.
In right triangles, the hypotenuse squared equals the sum of
the squares of the other sides. Cornerstone of geometry with
applications in navigation and architecture.
∇· E = ∂
ε0
∇· B = 0
∇× E = −∂B
∂t
∇× B = µ0J + µ0ε0 ∂E
∂t
Unified electricity and magnetism as manifestations of the
same force. Describes electromagnetic field behavior, predicting
waves traveling at light speed. Enabled technologies from radio
to smartphones.
1. Euler’s Identity
2. Pythagorean Theorem
e
iττ
+ 1 = 0
a2 + b2 = c2
3. The Fundamental THEorem of Calculus
4. Maxwell’s Equations
17 changes: 17 additions & 0 deletions olmocr/bench/sample_data/marker/mathfuncs_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## **The 20 Most Important Mathematical Equations**

A journey through the most elegant and influential formulas in mathematics

**1. Euler's Identity** Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry. **2. Pythagorean Theorem** In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture. *e* + ** 1 = 0 *a* + <sup>2</sup> *b* = <sup>2</sup> *c* 2

## **3. The Fundamental Theorem of Calculus**

## **4. Maxwell's Equations**

$$\int\_{a}^{b} f(\mathbf{x}) \, d\mathbf{x} = F(b) - F(a)$$

Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problemsolving.

∇ ⋅ **E** = *ε*0 *ρ* ∇ ⋅ **B** = 0 ∇ × **E** = − ∂*t***B** ∇ × **B** = *μ*0**J** + *μ*0*ε*<sup>0</sup> ∂*t***E**

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
17 changes: 17 additions & 0 deletions olmocr/bench/sample_data/marker/mathfuncs_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## **The 20 Most Important Mathematical Equations**

A journey through the most elegant and influential formulas in mathematics

**1. Euler's Identity** Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry. **2. Pythagorean Theorem** In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture. *e* + ** 1 = 0 *a* + <sup>2</sup> *b* = <sup>2</sup> *c* 2

## **3. The Fundamental Theorem of Calculus**

## **4. Maxwell's Equations**

$$\int\_{a}^{b} f(\mathbf{x}) \, d\mathbf{x} = F(b) - F(a)$$

Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problemsolving.

∇ ⋅ **E** = *ε*0 *ρ* ∇ ⋅ **B** = 0 ∇ × **E** = − ∂*t***B** ∇ × **B** = *μ*0**J** + *μ*0*ε*<sup>0</sup> ∂*t***E**

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
17 changes: 17 additions & 0 deletions olmocr/bench/sample_data/marker/mathfuncs_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## **The 20 Most Important Mathematical Equations**

A journey through the most elegant and influential formulas in mathematics

**1. Euler's Identity** Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry. **2. Pythagorean Theorem** In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture. *e* + ** 1 = 0 *a* + <sup>2</sup> *b* = <sup>2</sup> *c* 2

## **3. The Fundamental Theorem of Calculus**

## **4. Maxwell's Equations**

$$\int\_{a}^{b} f(\mathbf{x}) \, d\mathbf{x} = F(b) - F(a)$$

Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problemsolving.

∇ ⋅ **E** = *ε*0 *ρ* ∇ ⋅ **B** = 0 ∇ × **E** = − ∂*t***B** ∇ × **B** = *μ*0**J** + *μ*0*ε*<sup>0</sup> ∂*t***E**

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
17 changes: 17 additions & 0 deletions olmocr/bench/sample_data/marker/mathfuncs_4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## **The 20 Most Important Mathematical Equations**

A journey through the most elegant and influential formulas in mathematics

**1. Euler's Identity** Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry. **2. Pythagorean Theorem** In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture. *e* + ** 1 = 0 *a* + <sup>2</sup> *b* = <sup>2</sup> *c* 2

## **3. The Fundamental Theorem of Calculus**

## **4. Maxwell's Equations**

$$\int\_{a}^{b} f(\mathbf{x}) \, d\mathbf{x} = F(b) - F(a)$$

Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problemsolving.

∇ ⋅ **E** = *ε*0 *ρ* ∇ ⋅ **B** = 0 ∇ × **E** = − ∂*t***B** ∇ × **B** = *μ*0**J** + *μ*0*ε*<sup>0</sup> ∂*t***E**

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
17 changes: 17 additions & 0 deletions olmocr/bench/sample_data/marker/mathfuncs_5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## **The 20 Most Important Mathematical Equations**

A journey through the most elegant and influential formulas in mathematics

**1. Euler's Identity** Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry. **2. Pythagorean Theorem** In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture. *e* + ** 1 = 0 *a* + <sup>2</sup> *b* = <sup>2</sup> *c* 2

## **3. The Fundamental Theorem of Calculus**

## **4. Maxwell's Equations**

$$\int\_{a}^{b} f(\mathbf{x}) \, d\mathbf{x} = F(b) - F(a)$$

Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problemsolving.

∇ ⋅ **E** = *ε*0 *ρ* ∇ ⋅ **B** = 0 ∇ × **E** = − ∂*t***B** ∇ × **B** = *μ*0**J** + *μ*0*ε*<sup>0</sup> ∂*t***E**

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
19 changes: 19 additions & 0 deletions olmocr/bench/sample_data/olmocr_base_temp0_1/mathfuncs_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

| 1. Euler's Identity | 2. Pythagorean Theorem |
|--------------------|------------------------|
| \( e^{i\pi} + 1 = 0 \) | \( a^2 + b^2 = c^2 \) |

Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry.

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

| 3. The Fundamental Theorem of Calculus | 4. Maxwell's Equations |
|----------------------------------------|------------------------|
| \( \int_{a}^{b} f(x) \, dx = F(b) - F(a) \) | \( \nabla \cdot \mathbf{E} = \frac{Q}{\varepsilon_0} \) |

Establishes that differentiation and integration are inverse operations. If \( F \) is an antiderivative of \( f \), the definite integral equals \( F(b) - F(a) \). Revolutionized mathematical problem-solving.

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
19 changes: 19 additions & 0 deletions olmocr/bench/sample_data/olmocr_base_temp0_1/mathfuncs_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

| 1. Euler's Identity | 2. Pythagorean Theorem |
|---------------------|------------------------|
| \( e^{i\pi} + 1 = 0 \) | \( a^2 + b^2 = c^2 \) |

Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry.

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

| 3. The Fundamental Theorem of Calculus | 4. Maxwell's Equations |
|----------------------------------------|------------------------|
| \[ \int_{a}^{b} f(x) \, dx = F(b) - F(a) \] | \[ \nabla \cdot \mathbf{E} = \frac{Q}{\varepsilon_0} \] |

Establishes that differentiation and integration are inverse operations. If \( F \) is an antiderivative of \( f \), the definite integral equals \( F(b) - F(a) \). Revolutionized mathematical problem-solving.

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
19 changes: 19 additions & 0 deletions olmocr/bench/sample_data/olmocr_base_temp0_1/mathfuncs_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

| 1. Euler's Identity | 2. Pythagorean Theorem |
|--------------------|------------------------|
| \( e^{i\pi} + 1 = 0 \) | \( a^2 + b^2 = c^2 \) |

Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry.

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

| 3. The Fundamental Theorem of Calculus | 4. Maxwell's Equations |
|----------------------------------------|------------------------|
| \( \int_{a}^{b} f(x) \, dx = F(b) - F(a) \) | \( \nabla \cdot \mathbf{E} = \frac{Q}{\varepsilon_0} \) |

Establishes that differentiation and integration are inverse operations. If \( F \) is an antiderivative of \( f \), the definite integral equals \( F(b) - F(a) \). Revolutionized mathematical problem-solving.

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
19 changes: 19 additions & 0 deletions olmocr/bench/sample_data/olmocr_base_temp0_1/mathfuncs_4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

| 1. Euler's Identity | 2. Pythagorean Theorem |
|--------------------|------------------------|
| \( e^{i\pi} + 1 = 0 \) | \( a^2 + b^2 = c^2 \) |

Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry.

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

| 3. The Fundamental Theorem of Calculus | 4. Maxwell's Equations |
|----------------------------------------|------------------------|
| \( \int_{a}^{b} f(x) \, dx = F(b) - F(a) \) | \( \nabla \cdot \mathbf{E} = \frac{Q}{\varepsilon_0} \) |

Establishes that differentiation and integration are inverse operations. If F is an antiderivative of f, the definite integral equals F(b) - F(a). Revolutionized mathematical problem-solving.

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
19 changes: 19 additions & 0 deletions olmocr/bench/sample_data/olmocr_base_temp0_1/mathfuncs_5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

| 1. Euler's Identity | 2. Pythagorean Theorem |
|--------------------|------------------------|
| \( e^{i\pi} + 1 = 0 \) | \( a^2 + b^2 = c^2 \) |

Connects five fundamental constants (e, i, π, 1, 0), revealing the profound relationship between exponential functions and trigonometry.

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

| 3. The Fundamental Theorem of Calculus | 4. Maxwell's Equations |
|----------------------------------------|------------------------|
| \( \int_{a}^{b} f(x) \, dx = F(b) - F(a) \) | \( \nabla \cdot \mathbf{E} = \frac{Q}{\varepsilon_0} \) |

Establishes that differentiation and integration are inverse operations. If \( F \) is an antiderivative of \( f \), the definite integral equals \( F(b) - F(a) \). Revolutionized mathematical problem-solving.

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
42 changes: 42 additions & 0 deletions olmocr/bench/sample_data/olmocr_base_temp0_8/mathfuncs_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# The 20 Most Important Mathematical Equations

A journey through the most elegant and influential formulas in mathematics

---

**1. Euler's Identity**

\[ e^{i\pi} + 1 = 0 \]

Connects five fundamental constants (\(e, i, \pi, 1, 0\)), revealing the profound relationship between exponential functions and trigonometry.

---

**2. Pythagorean Theorem**

\[ a^2 + b^2 = c^2 \]

In right triangles, the hypotenuse squared equals the sum of the squares of the other sides. Cornerstone of geometry with applications in navigation and architecture.

---

**3. The Fundamental Theorem of Calculus**

\[ \int_a^b f(x) \, dx = F(b) - F(a) \]

Establishes that differentiation and integration are inverse operations. If \(F\) is an antiderivative of \(f\), the definite integral equals \(F(b) - F(a)\). Revolutionized mathematical problem-solving.

---

**4. Maxwell's Equations**

\[
\begin{align*}
\nabla \cdot \mathbf{E} &= \frac{Q}{\varepsilon_0} \\
\nabla \cdot \mathbf{B} &= 0 \\
\n\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
\n\nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t}
\end{align*}
\]

Unified electricity and magnetism as manifestations of the same force. Describes electromagnetic field behavior, predicting waves traveling at light speed. Enabled technologies from radio to smartphones.
Loading

0 comments on commit 438e68e

Please sign in to comment.