From 5b19f9ba2766fe8ad84d159be9aa81c7a2e00bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAnar=20Berg?= Date: Tue, 28 Nov 2023 12:48:44 -0800 Subject: [PATCH] Add randomized examples to demo playground on doc page Resolves: #99 --- docs/index.html | 8 ++++++-- docs/main.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/docs/index.html b/docs/index.html index b750205..7e19235 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,7 +31,7 @@

Mathup

- +
@@ -1001,7 +1001,7 @@

Operators

  • - sum_(n=0)^k a_n = a_0 + a_i + cdots + a_k + sum_(n=0)^k a_n = a_0 + a_1 + cdots + a_k
  • @@ -1787,6 +1787,10 @@

    Fenced Groups

  • +
  • + |(Psi(t):) = int Psi(x, t) |(x:) dx +
  • +
  • diff --git a/docs/main.js b/docs/main.js index 9de5e9c..341511b 100644 --- a/docs/main.js +++ b/docs/main.js @@ -89,6 +89,31 @@ function removePolyfill(outputEl, mathupEl) { } } +const DEMO_EQUATIONS = [ + "E[X] = int_(-oo)^oo x f(x) dx", + "sum_(n=0)^k a_n = a_0 + a_1 + cdots + a_k", + "e = sum_(n=0)^oo 1 / n!", + "vec x = a hat i + b hat j + c hat k", + "grad f(x,y) = ((del f)/(del x) (x, y), (del f)/(del y)(x,y))", + "oint_(del S) bf F * d bf s = dint_S grad xx bf F * d bf s", + "cc N(x | μ, σ^2) = 1 / (σ sqrt(2π)) e^(-1/2 (x-μ / σ)^2)", + "`Gamma`(theta | alpha, beta) = beta^alpha / Gamma(alpha) theta^(alpha - 1) e^(-beta theta)", + "P(A | B) = P(B | A)P(A) / P(B)", + String.raw`phi =.^\def a/b = a+b / a`, + "binom(n, k) = n! / k!(n-k)!", + "|(Psi(t):) = int Psi(x, t) |(x:) dx", + "<> = lim_(T->oo) 1/T int_(-T/2)^(T/2) V(t)^2 dt", + `[λ_0, λ_1, ...;] [p_(0 0), p_(0 1), ... + p_(1 0), p_(1 1), ... + vdots, vdots, ddots]`, + "||(bf x)||^2 = [x_1 ; x_2 ; x_3]*[x_1 ; x_2 ; x_3]", + `n! = { 1, if n=0 or n=1 + n(n-1)!, if n > 1`, + "x = -b+-sqrt(b^2 - 4ac) / 2a", + "ln x = int_1^x 1/t dt", + "bf F @ bf G: U sube RR^3 -> RR^2", +]; + /** * @returns {void} */ @@ -138,6 +163,9 @@ function setupPlayground() { return; } + tryInput.value = + DEMO_EQUATIONS[Math.floor(Math.random() * DEMO_EQUATIONS.length)]; + const tryMathUp = /** @type {MathUpElement} */ ( tryOutput.querySelector("math-up") );