From a6f2dd9433d09095cf560c7b3abef95f7b7ab49d Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 01/10] fix: correct force balance, orbit and coil orientation
in electromagnetism visualizations
---
.../electromagnetism/coulombs-law/ar.md | 4 ++--
.../electromagnetism/electric-potential/ar.md | 2 +-
.../electromagnetism/lorentz-force/ar.md | 6 ++---
.../electromagnetism/lorentz-force/en.md | 6 ++---
content/ui/ar/electric-field.yaml | 7 ++++++
content/ui/en/electric-field.yaml | 7 ++++++
src/viz/electromagnetism/ElectricField.vue | 22 ++++++++++-------
src/viz/electromagnetism/ElectricMotors.vue | 13 ++++++----
src/viz/electromagnetism/GeneratorsAndAc.vue | 8 +++----
src/viz/electromagnetism/LorentzForce.vue | 24 ++++++++++++-------
10 files changed, 65 insertions(+), 34 deletions(-)
create mode 100644 content/ui/ar/electric-field.yaml
create mode 100644 content/ui/en/electric-field.yaml
diff --git a/content/lessons/electromagnetism/coulombs-law/ar.md b/content/lessons/electromagnetism/coulombs-law/ar.md
index d8dbf6f1..d38e5a0f 100644
--- a/content/lessons/electromagnetism/coulombs-law/ar.md
+++ b/content/lessons/electromagnetism/coulombs-law/ar.md
@@ -17,8 +17,8 @@ variables:
## Try it
-1. تخيّل بالونين فُركا بالشعر والمسافة بينهما 1.5 m. اضبط «الشحنة q1» على 3 µC، و«الشحنة q2» على −3 µC، و«المسافة الفاصلة d» على 1.5 m. تعرض قراءة القوة بين الشحنتين (force between charges) القيمة 0.036 N مع كلمة attract، أي تجاذب.
-2. اسحب منزلق «الشحنة q2» من −3 إلى 3 µC. تبقى القراءة 0.036 N، لكن الكلمة تصير repel، أي تنافر. والسهم السميك على شحنة الاختبار السوداء يدور إلى اتجاه جديد.
+1. تخيّل بالونين فُركا بالشعر والمسافة بينهما 1.5 m. اضبط «الشحنة q1» على 3 µC، و«الشحنة q2» على −3 µC، و«المسافة الفاصلة d» على 1.5 m. تعرض قراءة «القوة بين الشحنتين» القيمة 0.036 N مع كلمة (تجاذب).
+2. اسحب منزلق «الشحنة q2» من −3 إلى 3 µC. تبقى القراءة 0.036 N، لكن الكلمة تصير (تنافر). والسهم السميك على شحنة الاختبار السوداء يدور إلى اتجاه جديد.
3. اسحب منزلق «المسافة الفاصلة d» من 1.5 m إلى 3 m. تنخفض القوة من 0.036 N إلى 0.009 N، فضعف المسافة يعني ربع القوة فقط.
## Real-life examples
diff --git a/content/lessons/electromagnetism/electric-potential/ar.md b/content/lessons/electromagnetism/electric-potential/ar.md
index ab951cf5..d4d0ecc7 100644
--- a/content/lessons/electromagnetism/electric-potential/ar.md
+++ b/content/lessons/electromagnetism/electric-potential/ar.md
@@ -16,7 +16,7 @@ variables:
## Try it
-1. تخيّل كرتين معدنيتين مشحونتين في ورشة عمل، تحمل كل منهما نحو 3 µC، والمسافة بينهما 4 m. اضبط «الشحنة q1» و«الشحنة q2» على 3 µC، و«المسافة الفاصلة d» على 4 m، و«نقطة الاختبار x» على 0، و«نقطة الاختبار y» على 1.5. تعرض قراءة الجهد (potential V at point) القيمة 21576 V.
+1. تخيّل كرتين معدنيتين مشحونتين في ورشة عمل، تحمل كل منهما نحو 3 µC، والمسافة بينهما 4 m. اضبط «الشحنة q1» و«الشحنة q2» على 3 µC، و«المسافة الفاصلة d» على 4 m، و«نقطة الاختبار x» على 0، و«نقطة الاختبار y» على 1.5. تعرض قراءة «الجهد V عند النقطة» القيمة 21576 V.
2. اسحب منزلق «نقطة الاختبار x» من 0 إلى 2، فتصير النقطة فوق الكرة الثانية تمامًا. يرتفع الجهد إلى نحو 24293 V. تابع إلى 4، فينخفض إلى نحو 15149 V لأنك ابتعدت عن الكرتين.
3. اخفض الآن منزلق «الشحنة q2» إلى −3 µC. تصير القراءة سالبة: نحو −6427 V. أعد «نقطة الاختبار x» إلى 0، في منتصف المسافة بين الكرتين، فتصير القراءة 0 V بالضبط.
diff --git a/content/lessons/electromagnetism/lorentz-force/ar.md b/content/lessons/electromagnetism/lorentz-force/ar.md
index a615ca35..0d24b698 100644
--- a/content/lessons/electromagnetism/lorentz-force/ar.md
+++ b/content/lessons/electromagnetism/lorentz-force/ar.md
@@ -11,14 +11,14 @@ variables:
- شحنة الجسيم، بمضاعفات الشحنة الأولية
- سرعة الجسيم
- شدة المجال المغناطيسي، ويكون داخلًا في الشاشة عندما يكون موجبًا
- - شدة مجال كهربائي منتظم، يشير إلى أعلى الشاشة
+ - شدة مجال كهربائي منتظم، يشير إلى أسفل الشاشة
---
## Try it
-1. تخيّل إلكترونًا ينحني داخل المجال المغناطيسي لأنبوب تلفاز قديم (CRT). أبقِ «الشحنة q» عند 1، و«السرعة v» عند 5، و«المجال المغناطيسي B» عند 1 T، و«المجال الكهربائي E» عند 0. ينحني الجسيم في قوس واسع ثم يخرج من الصورة، وتعرض القراءات نصف القطر (radius) 150 px والانحراف (deflects) إلى أسفل: down.
+1. تخيّل إلكترونًا ينحني داخل المجال المغناطيسي لأنبوب تلفاز قديم (CRT). أبقِ «الشحنة q» عند 1، و«السرعة v» عند 5، و«المجال المغناطيسي B» عند 1 T، و«المجال الكهربائي E» عند 0. ينحني الجسيم في قوس واسع ثم يخرج من الصورة، وتعرض القراءات نصف القطر (radius) 150 px والانحراف (deflects) إلى أعلى: up.
2. أبقِ «المجال الكهربائي E» عند 0 وأنزل منزلق «السرعة v» إلى 1. ينخفض نصف القطر إلى 30 px، فتصير الدورة كلها داخل الصورة ويدور الجسيم مرة بعد مرة.
-3. اسحب منزلق «الشحنة q» من 1 إلى −1. تتغيّر قراءة الانحراف (deflects) من down إلى up، أي إلى أعلى، وينحني الجسيم الآن في الاتجاه المعاكس.
+3. اسحب منزلق «الشحنة q» من 1 إلى −1. تتغيّر قراءة الانحراف (deflects) من up إلى down، أي إلى أسفل، وينحني الجسيم الآن في الاتجاه المعاكس.
## Real-life examples
diff --git a/content/lessons/electromagnetism/lorentz-force/en.md b/content/lessons/electromagnetism/lorentz-force/en.md
index c832e63a..20827072 100644
--- a/content/lessons/electromagnetism/lorentz-force/en.md
+++ b/content/lessons/electromagnetism/lorentz-force/en.md
@@ -13,14 +13,14 @@ variables:
- "the particle's charge, in multiples of the elementary charge"
- the particle's speed
- 'magnetic field strength, into the screen when positive'
- - 'uniform electric field strength, pointing up the screen'
+ - 'uniform electric field strength, pointing down the screen'
---
## Try it
-1. Picture an electron, curving inside the magnetic field of an old CRT television tube. Leave «charge q» at 1, «speed v» at 5, «magnetic field B» at 1 T and «electric field E» at 0. The particle bends along a wide arc and leaves the picture; the readouts show radius 150 px and deflects down.
+1. Picture an electron, curving inside the magnetic field of an old CRT television tube. Leave «charge q» at 1, «speed v» at 5, «magnetic field B» at 1 T and «electric field E» at 0. The particle bends along a wide arc and leaves the picture; the readouts show radius 150 px and deflects up.
2. Keep «electric field E» at 0 and drag «speed v» down to 1. The radius readout drops to 30 px, so the whole loop now fits in the picture and the particle goes round and round.
-3. Drag «charge q» from 1 to −1. The "deflects" readout changes from down to up, and the particle now curves the other way around.
+3. Drag «charge q» from 1 to −1. The "deflects" readout changes from up to down, and the particle now curves the other way around.
## Real-life examples
diff --git a/content/ui/ar/electric-field.yaml b/content/ui/ar/electric-field.yaml
new file mode 100644
index 00000000..ffd7a42b
--- /dev/null
+++ b/content/ui/ar/electric-field.yaml
@@ -0,0 +1,7 @@
+ef.hint: اسحب شحنة الاختبار السوداء · الأسهم تبيّن اتجاه المجال، والباهت منها مجال ضعيف
+ef.eAtPoint: '|E| عند النقطة'
+ef.forceOnTest: القوة على شحنة الاختبار
+ef.forceBetween: القوة بين الشحنتين
+ef.potential: الجهد V عند النقطة
+ef.repel: تنافر
+ef.attract: تجاذب
diff --git a/content/ui/en/electric-field.yaml b/content/ui/en/electric-field.yaml
new file mode 100644
index 00000000..798af372
--- /dev/null
+++ b/content/ui/en/electric-field.yaml
@@ -0,0 +1,7 @@
+ef.hint: drag the black test charge · arrows show field direction, faint = weak
+ef.eAtPoint: '|E| at point'
+ef.forceOnTest: force on test charge
+ef.forceBetween: force between charges
+ef.potential: potential V at point
+ef.repel: repel
+ef.attract: attract
diff --git a/src/viz/electromagnetism/ElectricField.vue b/src/viz/electromagnetism/ElectricField.vue
index 8c0dc979..97a58e6e 100644
--- a/src/viz/electromagnetism/ElectricField.vue
+++ b/src/viz/electromagnetism/ElectricField.vue
@@ -1,6 +1,7 @@
@@ -132,6 +137,7 @@ const readouts = computed(() => [
+
@@ -147,7 +153,7 @@ const readouts = computed(() => [
q2
- drag the black test charge · arrows show field direction, faint = weak
+ {{ t('ef.hint') }}
diff --git a/src/viz/electromagnetism/ElectricMotors.vue b/src/viz/electromagnetism/ElectricMotors.vue
index 2e94ca22..411f6084 100644
--- a/src/viz/electromagnetism/ElectricMotors.vue
+++ b/src/viz/electromagnetism/ElectricMotors.vue
@@ -5,8 +5,9 @@ import { t } from '../../i18n'
import Readouts from '../../components/Readouts.vue'
// electromagnetism/electric-motors. params: N, I, A, B, theta (rad). tau = N*I*A*B*sin(theta).
-// The two dots are the coil's near and far wires, seen end-on, at angle theta from the field axis
-// (horizontal, N pole left, S pole right). A dot (out of the page) and a cross (into the page) show
+// The two dots are the coil's near and far wires, seen end-on. theta is the angle between the coil's
+// normal and the field axis (horizontal, N pole left, S pole right), so the line joining the wires sits
+// at theta - 90deg: along the field at theta = 90deg (peak torque), across it at 0 and 180deg (none). A dot (out of the page) and a cross (into the page) show
// current direction; the split-ring commutator below flips which wire is which exactly at theta = 0
// and pi, keeping the torque arrow's sense the same all the way round.
const props = defineProps<{ params: Record; options: Record }>()
@@ -26,8 +27,8 @@ const theta = computed(() => props.params.theta ?? Math.PI / 2)
const tau = computed(() => N.value * I.value * A.value * B.value * Math.sin(theta.value))
-const wire1 = computed(() => ({ x: CX + RC * Math.cos(theta.value), y: CY - RC * Math.sin(theta.value) }))
-const wire2 = computed(() => ({ x: CX - RC * Math.cos(theta.value), y: CY + RC * Math.sin(theta.value) }))
+const wire1 = computed(() => ({ x: CX + RC * Math.sin(theta.value), y: CY + RC * Math.cos(theta.value) }))
+const wire2 = computed(() => ({ x: CX - RC * Math.sin(theta.value), y: CY - RC * Math.cos(theta.value) }))
const outward = computed(() => Math.sin(theta.value) >= 0) // wire1 current direction
// torque arc: a curved arrow whose sweep length shows |tau|; always drawn counter-clockwise, the
@@ -62,8 +63,10 @@ function drag(e: PointerEvent) {
const box = svg.value.getBoundingClientRect()
const px = ((e.clientX - box.left) / box.width) * W
const py = ((e.clientY - box.top) / box.height) * H
- let ang = Math.atan2(-(py - CY), px - CX)
+ // the pointer grabs wire 1, which sits 90deg behind theta
+ let ang = Math.atan2(-(py - CY), px - CX) + Math.PI / 2
if (ang < 0) ang += 2 * Math.PI
+ if (ang >= 2 * Math.PI) ang -= 2 * Math.PI
emit('set', 'theta', ang)
}
function down(e: PointerEvent) {
diff --git a/src/viz/electromagnetism/GeneratorsAndAc.vue b/src/viz/electromagnetism/GeneratorsAndAc.vue
index d01acecd..c143ca95 100644
--- a/src/viz/electromagnetism/GeneratorsAndAc.vue
+++ b/src/viz/electromagnetism/GeneratorsAndAc.vue
@@ -6,8 +6,8 @@ import Readouts from '../../components/Readouts.vue'
// electromagnetism/generators-and-ac. params: N, B, A, rpm, t. f = rpm/60, Vpeak = N*B*A*2*pi*f,
// v(t) = Vpeak*sin(2*pi*f*t). The wave on the right is auto-scaled to +-Vpeak (which spans volts to
-// kilovolts across presets); the small schematic on the left shows the coil at its matching angle
-// 2*pi*f*t, and a lamp whose brightness follows |v(t)|/Vpeak.
+// kilovolts across presets); the small schematic on the left shows the coil turned by
+// 2*pi*f*t from face-on to the field (wires across the field, v = 0), and a lamp whose brightness follows |v(t)|/Vpeak.
const props = defineProps<{ params: Record; options: Record }>()
const emit = defineEmits<{ set: [name: string, value: number] }>()
@@ -70,8 +70,8 @@ const SC_CX = 155
const SC_CY = 110
const SC_R = 46
const outward = computed(() => v.value >= 0)
-const coilEnd1 = computed(() => ({ x: SC_CX + SC_R * Math.cos(phi.value), y: SC_CY - SC_R * Math.sin(phi.value) }))
-const coilEnd2 = computed(() => ({ x: SC_CX - SC_R * Math.cos(phi.value), y: SC_CY + SC_R * Math.sin(phi.value) }))
+const coilEnd1 = computed(() => ({ x: SC_CX - SC_R * Math.sin(phi.value), y: SC_CY - SC_R * Math.cos(phi.value) }))
+const coilEnd2 = computed(() => ({ x: SC_CX + SC_R * Math.sin(phi.value), y: SC_CY + SC_R * Math.cos(phi.value) }))
const lampFrac = computed(() => (Vpeak.value > 0 ? Math.abs(v.value) / Vpeak.value : 0))
const readouts = computed(() => [
diff --git a/src/viz/electromagnetism/LorentzForce.vue b/src/viz/electromagnetism/LorentzForce.vue
index 15a0f066..326b3442 100644
--- a/src/viz/electromagnetism/LorentzForce.vue
+++ b/src/viz/electromagnetism/LorentzForce.vue
@@ -10,7 +10,7 @@ const W = 800
const H = 480
const K_RAD = 30 // px per (v / |q B|) — calibrates the visible cyclotron radius
const K_B = 1 / K_RAD
-const K_E = 1 / (2 * K_RAD)
+const K_E = K_B
const TRAIL_N = 200
const q = computed(() => props.params.q ?? 1)
@@ -31,10 +31,18 @@ reset()
watch(() => [q.value, v.value, B.value, E.value], reset)
function step() {
- const ax = -K_B * q.value * B.value * state.vy
- const ay = K_B * q.value * B.value * state.vx - K_E * q.value * E.value
- state.vx += ax
- state.vy += ay
+ // Boris step: half electric kick, exact rotation by the magnetic field, half kick.
+ // Keeps the speed constant when E = 0 (closed circle) and gives a straight line at v = E/B.
+ // Screen y points down: with B into the screen a positive charge moving right is pushed up, and E points down.
+ const t = (K_B * q.value * B.value) / 2
+ const c = (1 - t * t) / (1 + t * t)
+ const s = (2 * t) / (1 + t * t)
+ const kick = (K_E * q.value * E.value) / 2
+ const vy0 = state.vy + kick
+ const vx1 = c * state.vx + s * vy0
+ const vy1 = c * vy0 - s * state.vx
+ state.vx = vx1
+ state.vy = vy1 + kick
state.x += state.vx
state.y += state.vy
state.trail.push([state.x, state.y])
@@ -66,7 +74,7 @@ const fMag = computed(() => Math.abs(q.value * v.value * B.value))
const radius = computed(() => (q.value !== 0 && B.value !== 0 ? (K_RAD * v.value) / Math.abs(q.value * B.value) : NaN))
const period = computed(() => (Number.isFinite(radius.value) ? (2 * Math.PI * radius.value) / v.value : NaN))
const deflect = computed(() => {
- const ay0 = K_B * q.value * B.value * v.value - K_E * q.value * E.value
+ const ay0 = K_E * q.value * E.value - K_B * q.value * B.value * v.value
if (Math.abs(ay0) < 1e-6) return 'none'
return ay0 > 0 ? 'down' : 'up'
})
@@ -77,8 +85,8 @@ const velLine = computed(() => {
return { x1: state.x, y1: state.y, x2: state.x + state.vx * s, y2: state.y + state.vy * s }
})
const forceLine = computed(() => {
- const ax = -K_B * q.value * B.value * state.vy
- const ay = K_B * q.value * B.value * state.vx - K_E * q.value * E.value
+ const ax = K_B * q.value * B.value * state.vy
+ const ay = K_E * q.value * E.value - K_B * q.value * B.value * state.vx
const m = Math.hypot(ax, ay) || 1e-9
const s = 26 / m
return { x1: state.x, y1: state.y, x2: state.x + ax * s, y2: state.y + ay * s }
From 4ead8ff59fde747915d49f0731fb49a808468e70 Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 02/10] fix: separate Stern-Gerlach spots, expansion state
readout and electron shell filling
---
.../schrodinger-equation-particle-in-a-box/ar.md | 2 +-
.../schrodinger-equation-particle-in-a-box/en.md | 2 +-
.../lesson.yaml | 2 +-
content/ui/ar/expansion.yaml | 1 +
content/ui/en/expansion.yaml | 1 +
src/viz/cosmos/Expansion.vue | 6 ++++--
src/viz/elements.ts | 12 ++++++++----
src/viz/quantum/SternGerlach.vue | 11 ++++++-----
8 files changed, 23 insertions(+), 14 deletions(-)
create mode 100644 content/ui/ar/expansion.yaml
create mode 100644 content/ui/en/expansion.yaml
diff --git a/content/lessons/quantum/schrodinger-equation-particle-in-a-box/ar.md b/content/lessons/quantum/schrodinger-equation-particle-in-a-box/ar.md
index 88b4a32f..483b2c6b 100644
--- a/content/lessons/quantum/schrodinger-equation-particle-in-a-box/ar.md
+++ b/content/lessons/quantum/schrodinger-equation-particle-in-a-box/ar.md
@@ -29,7 +29,7 @@ charts: []
## Test yourself
1. اختر المستوى الذي تكون فيه قراءة الطاقة 9 أضعاف طاقة الحالة الأدنى.
-2. ارفع المستوى إلى 4 أو أعلى.
+2. ارفع المستوى إلى 5 أو أعلى.
3. اختر المستوى الذي تكون فيه قراءة الطاقة 16 ضعف طاقة الحالة الأدنى.
## Intuition
diff --git a/content/lessons/quantum/schrodinger-equation-particle-in-a-box/en.md b/content/lessons/quantum/schrodinger-equation-particle-in-a-box/en.md
index b87f181b..029bae23 100644
--- a/content/lessons/quantum/schrodinger-equation-particle-in-a-box/en.md
+++ b/content/lessons/quantum/schrodinger-equation-particle-in-a-box/en.md
@@ -30,7 +30,7 @@ charts: []
## Test yourself
1. Reach the energy level where the energy readout is nine times the ground-state energy.
-2. Push the level to 4 or higher.
+2. Push the level to 5 or higher.
3. Reach the energy level where the energy readout is sixteen times the ground-state energy.
## Intuition
diff --git a/content/lessons/quantum/schrodinger-equation-particle-in-a-box/lesson.yaml b/content/lessons/quantum/schrodinger-equation-particle-in-a-box/lesson.yaml
index 41b9b3d8..0849fe1f 100644
--- a/content/lessons/quantum/schrodinger-equation-particle-in-a-box/lesson.yaml
+++ b/content/lessons/quantum/schrodinger-equation-particle-in-a-box/lesson.yaml
@@ -46,7 +46,7 @@ challenges:
- check: n^2
target: 9
tol: 0.5
- - check: n >= 4
+ - check: n >= 5
- check: n^2
target: 16
tol: 0.5
diff --git a/content/ui/ar/expansion.yaml b/content/ui/ar/expansion.yaml
new file mode 100644
index 00000000..0311a66c
--- /dev/null
+++ b/content/ui/ar/expansion.yaml
@@ -0,0 +1 @@
+exp.steady: ثابت، لا يتسارع ولا يتباطأ
diff --git a/content/ui/en/expansion.yaml b/content/ui/en/expansion.yaml
new file mode 100644
index 00000000..9da336eb
--- /dev/null
+++ b/content/ui/en/expansion.yaml
@@ -0,0 +1 @@
+exp.steady: steady, neither speeding up nor slowing down
diff --git a/src/viz/cosmos/Expansion.vue b/src/viz/cosmos/Expansion.vue
index 49f2dfd7..7d103b84 100644
--- a/src/viz/cosmos/Expansion.vue
+++ b/src/viz/cosmos/Expansion.vue
@@ -33,7 +33,9 @@ const main = computed(() => history(om.value, ol.value))
const noDE = computed(() => history(om.value, 0))
const tMax = 2.2
const now = computed(() => main.value[Math.min(main.value.length - 1, Math.round(tv.value * (main.value.length - 1)))])
-const accel = computed(() => { const i = Math.round(tv.value * (main.value.length - 1)); const p = main.value; if (i < 2 || i > p.length - 2) return 0; return p[i + 1].a - 2 * p[i].a + p[i - 1].a })
+// d²a/dt² from the Friedmann equation: dark energy pushes (ΩΛ a), matter brakes (Ωm / 2a²); zero for an empty universe
+const accel = computed(() => ol.value * now.value.a - om.value / (2 * now.value.a ** 2))
+const stateKey = computed(() => (accel.value > 1e-9 ? 'exp.speedingUp' : accel.value < -1e-9 ? 'exp.slowingDown' : 'exp.steady'))
const galaxies = Array.from({ length: 26 }, (_, i) => ({ x: ((i * 0.6180339) % 1) * 2 - 1, y: ((i * 0.41421356) % 1) * 2 - 1 }))
const gx = (x: number) => 200 + x * 160 * Math.min(1.25, now.value.a / 1.2)
const gy = (y: number) => 240 + y * 160 * Math.min(1.25, now.value.a / 1.2)
@@ -43,7 +45,7 @@ const curve = (h: { t: number; a: number }[]) => h.filter((_, i) => i % 3 === 0)
const readouts = computed(() => [
{ label: t('exp.scale'), value: fmt(now.value.a, 2), color: 'var(--accent-2)' },
{ label: t('exp.time'), value: `${fmt((now.value.t * 14.4), 1)} ${t('exp.billionYears')}` },
- { label: t('exp.state'), value: accel.value > 1e-7 ? t('exp.speedingUp') : t('exp.slowingDown'), color: accel.value > 1e-7 ? 'var(--neg)' : 'var(--accent)' },
+ { label: t('exp.state'), value: t(stateKey.value), color: accel.value > 1e-9 ? 'var(--neg)' : 'var(--accent)' },
])
diff --git a/src/viz/elements.ts b/src/viz/elements.ts
index 116d1ae8..1b2c5ac2 100644
--- a/src/viz/elements.ts
+++ b/src/viz/elements.ts
@@ -4,11 +4,15 @@ export type Cat = 'alkali' | 'alkaline' | 'transition' | 'post' | 'metalloid' |
export interface El { z: number; s: string; n: string; m: number; g: number; p: number; c: Cat }
const raw = `1 H Hydrogen 1.008 1 1 nonmetal|2 He Helium 4.003 18 1 noble|3 Li Lithium 6.94 1 2 alkali|4 Be Beryllium 9.012 2 2 alkaline|5 B Boron 10.81 13 2 metalloid|6 C Carbon 12.011 14 2 nonmetal|7 N Nitrogen 14.007 15 2 nonmetal|8 O Oxygen 15.999 16 2 nonmetal|9 F Fluorine 18.998 17 2 halogen|10 Ne Neon 20.180 18 2 noble|11 Na Sodium 22.990 1 3 alkali|12 Mg Magnesium 24.305 2 3 alkaline|13 Al Aluminium 26.982 13 3 post|14 Si Silicon 28.085 14 3 metalloid|15 P Phosphorus 30.974 15 3 nonmetal|16 S Sulfur 32.06 16 3 nonmetal|17 Cl Chlorine 35.45 17 3 halogen|18 Ar Argon 39.948 18 3 noble|19 K Potassium 39.098 1 4 alkali|20 Ca Calcium 40.078 2 4 alkaline|21 Sc Scandium 44.956 3 4 transition|22 Ti Titanium 47.867 4 4 transition|23 V Vanadium 50.942 5 4 transition|24 Cr Chromium 51.996 6 4 transition|25 Mn Manganese 54.938 7 4 transition|26 Fe Iron 55.845 8 4 transition|27 Co Cobalt 58.933 9 4 transition|28 Ni Nickel 58.693 10 4 transition|29 Cu Copper 63.546 11 4 transition|30 Zn Zinc 65.38 12 4 transition|31 Ga Gallium 69.723 13 4 post|32 Ge Germanium 72.630 14 4 metalloid|33 As Arsenic 74.922 15 4 metalloid|34 Se Selenium 78.971 16 4 nonmetal|35 Br Bromine 79.904 17 4 halogen|36 Kr Krypton 83.798 18 4 noble|37 Rb Rubidium 85.468 1 5 alkali|38 Sr Strontium 87.62 2 5 alkaline|39 Y Yttrium 88.906 3 5 transition|40 Zr Zirconium 91.224 4 5 transition|41 Nb Niobium 92.906 5 5 transition|42 Mo Molybdenum 95.95 6 5 transition|43 Tc Technetium 98 7 5 transition|44 Ru Ruthenium 101.07 8 5 transition|45 Rh Rhodium 102.91 9 5 transition|46 Pd Palladium 106.42 10 5 transition|47 Ag Silver 107.87 11 5 transition|48 Cd Cadmium 112.41 12 5 transition|49 In Indium 114.82 13 5 post|50 Sn Tin 118.71 14 5 post|51 Sb Antimony 121.76 15 5 metalloid|52 Te Tellurium 127.60 16 5 metalloid|53 I Iodine 126.90 17 5 halogen|54 Xe Xenon 131.29 18 5 noble|55 Cs Caesium 132.91 1 6 alkali|56 Ba Barium 137.33 2 6 alkaline|57 La Lanthanum 138.91 0 6 lanthanide|58 Ce Cerium 140.12 0 6 lanthanide|59 Pr Praseodymium 140.91 0 6 lanthanide|60 Nd Neodymium 144.24 0 6 lanthanide|61 Pm Promethium 145 0 6 lanthanide|62 Sm Samarium 150.36 0 6 lanthanide|63 Eu Europium 151.96 0 6 lanthanide|64 Gd Gadolinium 157.25 0 6 lanthanide|65 Tb Terbium 158.93 0 6 lanthanide|66 Dy Dysprosium 162.50 0 6 lanthanide|67 Ho Holmium 164.93 0 6 lanthanide|68 Er Erbium 167.26 0 6 lanthanide|69 Tm Thulium 168.93 0 6 lanthanide|70 Yb Ytterbium 173.05 0 6 lanthanide|71 Lu Lutetium 174.97 3 6 lanthanide|72 Hf Hafnium 178.49 4 6 transition|73 Ta Tantalum 180.95 5 6 transition|74 W Tungsten 183.84 6 6 transition|75 Re Rhenium 186.21 7 6 transition|76 Os Osmium 190.23 8 6 transition|77 Ir Iridium 192.22 9 6 transition|78 Pt Platinum 195.08 10 6 transition|79 Au Gold 196.97 11 6 transition|80 Hg Mercury 200.59 12 6 transition|81 Tl Thallium 204.38 13 6 post|82 Pb Lead 207.2 14 6 post|83 Bi Bismuth 208.98 15 6 post|84 Po Polonium 209 16 6 post|85 At Astatine 210 17 6 halogen|86 Rn Radon 222 18 6 noble`
export const elements: El[] = raw.split('|').map((r) => { const [z, s, n, m, g, p, c] = r.split(' '); return { z: +z, s, n, m: +m, g: +g, p: +p, c: c as Cat } })
-/** Electron shells (2, 8, 18, …) by simple filling for a quick sketch. */
+/** Electrons per shell (K, L, M, …) in the real ground state: subshells fill in Aufbau order, plus the known exceptions. */
+const AUFBAU: [number, number][] = [[1, 2], [2, 2], [2, 6], [3, 2], [3, 6], [4, 2], [3, 10], [4, 6], [5, 2], [4, 10], [5, 6], [6, 2], [4, 14], [5, 10], [6, 6]] // [shell n, capacity]
+// z: [from shell, to shell, electrons moved] — Cr, Cu, Nb, Mo, Ru, Rh, Pd, Ag, La, Ce, Gd, Pt, Au
+const SHELL_FIX: Record = { 24: [4, 3, 1], 29: [4, 3, 1], 41: [5, 4, 1], 42: [5, 4, 1], 44: [5, 4, 1], 45: [5, 4, 1], 46: [5, 4, 2], 47: [5, 4, 1], 57: [4, 5, 1], 58: [4, 5, 1], 64: [4, 5, 1], 78: [6, 5, 1], 79: [6, 5, 1] }
export function shells(z: number): number[] {
- const cap = [2, 8, 18, 32, 32, 18, 8]
const out: number[] = []
let left = z
- for (const c of cap) { if (left <= 0) break; const k = Math.min(c, left); out.push(k); left -= k }
- return out
+ for (const [n, c] of AUFBAU) { if (left <= 0) break; const k = Math.min(c, left); out[n - 1] = (out[n - 1] ?? 0) + k; left -= k }
+ const fix = SHELL_FIX[z]
+ if (fix) { out[fix[0] - 1] -= fix[2]; out[fix[1] - 1] += fix[2] }
+ return out.filter((k) => k > 0)
}
diff --git a/src/viz/quantum/SternGerlach.vue b/src/viz/quantum/SternGerlach.vue
index fb3c312a..c3691e25 100644
--- a/src/viz/quantum/SternGerlach.vue
+++ b/src/viz/quantum/SternGerlach.vue
@@ -14,8 +14,10 @@ const H = 480
const G = computed(() => props.params.G ?? 6)
const v = computed(() => props.params.v ?? 650)
const sep = computed(() => (21300 * G.value) / v.value ** 2) // mm
-const PX_PER_MM = 150
+const PX_PER_MM = 190
const halfPx = computed(() => Math.min(190, (sep.value * PX_PER_MM) / 2))
+// each spot's spread shrinks with the separation, so the two spots never merge (closest: 0.053 mm)
+const spread = computed(() => Math.min(10, 0.8 * halfPx.value))
const CY = 240
const OVEN_X = 70
@@ -23,14 +25,13 @@ const MAGNET_X0 = 230
const MAGNET_X1 = 380
const SCREEN_X = 600
-const hits = ref<{ y: number; up: boolean }[]>([])
+const hits = ref<{ j: number; up: boolean }[]>([])
let raf = 0
let last = 0
let acc = 0
function spawn() {
const up = Math.random() < 0.5
- const jitter = (Math.random() - 0.5) * 10
- hits.value.push({ y: CY + (up ? -halfPx.value : halfPx.value) + jitter, up })
+ hits.value.push({ j: Math.random() - 0.5, up })
if (hits.value.length > 500) hits.value.splice(0, hits.value.length - 500)
}
function tick(now: number) {
@@ -81,7 +82,7 @@ const readouts = computed(() => [
-
+
{{ t('sg.screen') }}
{{ t('sg.actual') }}
From 32c4edc5a1799c1fb1194057e25dd1873078e1d0 Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 03/10] fix: nuclear visualizations show correct elements and a
gradual subcritical chain
---
content/lessons/nuclear/binding-energy/ar.md | 2 +-
content/lessons/nuclear/binding-energy/en.md | 2 +-
content/lessons/nuclear/chain-reaction/ar.md | 2 +-
content/lessons/nuclear/chain-reaction/en.md | 2 +-
content/lessons/nuclear/nuclear-fission/ar.md | 4 ++--
content/lessons/nuclear/nuclear-fission/en.md | 4 ++--
content/lessons/nuclear/nuclear-fission/lesson.yaml | 4 ++--
content/lessons/nuclear/nuclear-fusion/ar.md | 2 +-
content/lessons/nuclear/nuclear-fusion/en.md | 2 +-
content/lessons/nuclear/nuclear-fusion/lesson.yaml | 2 +-
content/lessons/nuclear/radioactive-decay/ar.md | 4 ++--
content/lessons/nuclear/radioactive-decay/en.md | 4 ++--
content/lessons/nuclear/radioactive-decay/lesson.yaml | 4 ++--
src/viz/nuclear/BindingEnergy.vue | 3 +++
src/viz/nuclear/ChainReaction.vue | 3 ++-
src/viz3d/nuclear/BindingEnergy3D.vue | 3 +++
src/viz3d/nuclear/ChainReaction3D.vue | 2 +-
17 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/content/lessons/nuclear/binding-energy/ar.md b/content/lessons/nuclear/binding-energy/ar.md
index 4671578e..da3d3698 100644
--- a/content/lessons/nuclear/binding-energy/ar.md
+++ b/content/lessons/nuclear/binding-energy/ar.md
@@ -18,7 +18,7 @@ charts: []
## Try it
1. ارفع منزلق «العدد الكتلي A» من 12 إلى 20. ترتفع قراءة «لكل نوية» من 7.2 إلى 8.01 MeV: تصعد النقطة المعلَّمة المنحنى بسرعة في البداية، فكل نوية جديدة تضيف تقريبًا كامل طاقة الربط التي تنالها نوية في عمق النواة.
-2. تابع التحريك حتى تستقر النقطة عند القمة، عند A = 60، حيث تقرأ «لكل نوية» القيمة 8.84 MeV. هذه منطقة الحديد والنيكل، أشد الأنوية تماسكًا على الإطلاق.
+2. تابع التحريك حتى تستقر النقطة عند القمة، عند A = 62، حيث تقرأ «لكل نوية» القيمة 8.84 MeV. هذه منطقة الحديد والنيكل، أشد الأنوية تماسكًا على الإطلاق.
3. تابع نحو الأنوية الثقيلة، بعد A = 150، وصولًا إلى A = 235، وهو العدد الكتلي لليورانيوم-235. تنخفض قراءة «لكل نوية» إلى نحو 7.6 MeV والمنحنى ينحدر من جديد على اليمين.
## Real-life examples
diff --git a/content/lessons/nuclear/binding-energy/en.md b/content/lessons/nuclear/binding-energy/en.md
index b3a8eea1..66d2edaf 100644
--- a/content/lessons/nuclear/binding-energy/en.md
+++ b/content/lessons/nuclear/binding-energy/en.md
@@ -17,7 +17,7 @@ charts: []
## Try it
1. Drag slider "mass number A" up from 12 to 20. The readout "per nucleon" climbs from 7.2 to 8.01 MeV: the marked dot climbs the curve fast at first, each extra nucleon adding almost the full binding energy a deep interior nucleon gets.
-2. Keep dragging until the dot sits at the very top, at A = 60, where "per nucleon" reads 8.84 MeV — the neighbourhood of iron and nickel, the most tightly bound nuclei that exist.
+2. Keep dragging until the dot sits at the very top, at A = 62, where "per nucleon" reads 8.84 MeV — the neighbourhood of iron and nickel, the most tightly bound nuclei that exist.
3. Keep going into heavy territory, past A = 150, all the way to A = 235, the mass number of uranium-235. "per nucleon" falls to about 7.6 MeV as the curve slopes back down on the right.
## Real-life examples
diff --git a/content/lessons/nuclear/chain-reaction/ar.md b/content/lessons/nuclear/chain-reaction/ar.md
index 91e7e282..9e20493b 100644
--- a/content/lessons/nuclear/chain-reaction/ar.md
+++ b/content/lessons/nuclear/chain-reaction/ar.md
@@ -14,7 +14,7 @@ charts: []
## Try it
1. اضبط «معامل التضاعف k» على 1.00 بالضبط وارفع «الأجيال» إلى 12. تنمو الشجرة نقطة واحدة في كل صف إلى الأبد: يبقى «العدد» عند 1 وتقرأ «الحالة» كلمة يستقر. هذا تفاعل متسلسل ثابت.
-2. أنزل k إلى 0.7 واضغط «من البداية». لا ينجح الانشطار الأول في إشعال انشطار آخر: يصير «العدد» 0 من الجيل 1 فصاعدًا وتقرأ «الحالة» كلمة ينطفئ.
+2. أنزل k إلى 0.7 واضغط «من البداية». ينجح التفاعل في انشطار واحد آخر فقط ثم يتوقف: يصير «العدد» 0 من الجيل 2 فصاعدًا وتقرأ «الحالة» كلمة ينطفئ. جرّب k = 0.9 أيضًا: يستمر التفاعل مدة أطول، حتى الجيل 6.
3. ارفع k إلى 2.00 واضغط «من البداية». يتّسع كل صف إلى ضعف سابقه، 1 ثم 2 ثم 4 ثم 8 ثم 16، ويقرأ «العدد» 64 عند الجيل 6 و4096 عند الجيل 12.
## Real-life examples
diff --git a/content/lessons/nuclear/chain-reaction/en.md b/content/lessons/nuclear/chain-reaction/en.md
index 6827efd8..ff9ff228 100644
--- a/content/lessons/nuclear/chain-reaction/en.md
+++ b/content/lessons/nuclear/chain-reaction/en.md
@@ -13,7 +13,7 @@ charts: []
## Try it
1. Set "multiplication factor k" to exactly 1.00 and drag "generations" up to 12. The tree grows one node per row, forever: "population" stays at 1 and "status" reads holding steady — a steady chain reaction.
-2. Lower k to 0.7 and press restart. The first fission fails to start another: "population" drops to 0 from generation 1 on and "status" reads dying out.
+2. Lower k to 0.7 and press restart. The chain manages just one more fission and then stops: "population" drops to 0 from generation 2 on and "status" reads dying out. Try k = 0.9 too: the chain lasts longer, until generation 6.
3. Raise k to 2.00 and restart. Each row fans out twice as wide as the last — 1, 2, 4, 8, 16 — and "population" reads 64 at generation 6 and 4096 at generation 12.
## Real-life examples
diff --git a/content/lessons/nuclear/nuclear-fission/ar.md b/content/lessons/nuclear/nuclear-fission/ar.md
index 2bbabd5e..fab99d8c 100644
--- a/content/lessons/nuclear/nuclear-fission/ar.md
+++ b/content/lessons/nuclear/nuclear-fission/ar.md
@@ -25,9 +25,9 @@ charts: []
## Test yourself
-1. أطلق نيوترونًا بطيئًا، أقل من 5000 km/s، حتى النهاية وراقب اكتمال الانشطار.
+1. أبطئ النيوترون إلى 400 km/s أو أقل (لكن ليس صفرًا)، ثم أطلقه حتى النهاية وراقب اكتمال الانشطار.
2. أطلق نيوترونًا سريعًا، 5000 km/s أو أكثر، حتى النهاية وتأكّد أنه يرتدّ فقط.
-3. أوقف النواة وهي ممتدة على هيئة دمبل، بين الزمن 30 والزمن 55.
+3. ارفع «سرعة النيوترون» إلى ما بين 2000 و4800 km/s، وهي سرعة ما زالت بطيئة بما يكفي لتنشطر النواة، وأوقف النواة وهي ممتدة على هيئة دمبل، بين الزمن 30 والزمن 55.
## Intuition
diff --git a/content/lessons/nuclear/nuclear-fission/en.md b/content/lessons/nuclear/nuclear-fission/en.md
index ed917bfe..af7ec466 100644
--- a/content/lessons/nuclear/nuclear-fission/en.md
+++ b/content/lessons/nuclear/nuclear-fission/en.md
@@ -24,9 +24,9 @@ charts: []
## Test yourself
-1. Run a slow neutron, below 5,000 km/s, all the way to the end and watch the fission complete.
+1. Slow the neutron down to 400 km/s or less (but not zero), then run it all the way to the end and watch the fission complete.
2. Run a fast neutron, 5,000 km/s or above, all the way to the end and confirm it only bounces off.
-3. Catch the nucleus stretched into its dumbbell shape, somewhere between time 30 and time 55.
+3. Raise "neutron speed" to between 2,000 and 4,800 km/s, still slow enough to split the nucleus, and catch it stretched into its dumbbell shape, somewhere between time 30 and time 55.
## Intuition
diff --git a/content/lessons/nuclear/nuclear-fission/lesson.yaml b/content/lessons/nuclear/nuclear-fission/lesson.yaml
index 39b7664b..a9d97b8f 100644
--- a/content/lessons/nuclear/nuclear-fission/lesson.yaml
+++ b/content/lessons/nuclear/nuclear-fission/lesson.yaml
@@ -47,6 +47,6 @@ presets:
- speed: 1000
time: 40
challenges:
- - check: speed > 0 and speed < 5000 and time >= 95
+ - check: speed > 0 and speed <= 400 and time >= 95
- check: speed >= 5000 and time >= 95
- - check: speed > 0 and speed < 5000 and time >= 30 and time <= 55
+ - check: speed >= 2000 and speed < 5000 and time >= 30 and time <= 55
diff --git a/content/lessons/nuclear/nuclear-fusion/ar.md b/content/lessons/nuclear/nuclear-fusion/ar.md
index ca813017..1e740d8d 100644
--- a/content/lessons/nuclear/nuclear-fusion/ar.md
+++ b/content/lessons/nuclear/nuclear-fusion/ar.md
@@ -27,7 +27,7 @@ charts: []
1. أبقِ «الحرارة» تحت 1 و«الحصر» تحت 0.5، ثم شغّل حتى الزمن 80 أو أكثر. يجب أن تبقى أحداث الاندماج نادرة.
2. ارفع «الحرارة» فوق 3 و«الحصر» فوق 0.8، ثم شغّل حتى الزمن 80 أو أكثر. يجب أن تظهر عدة أحداث اندماج.
-3. شغّل حتى الزمن 150 كاملًا وعُدَّ الأنوية التي بقيت.
+3. ارفع «الحرارة» فوق 3 واخفض «الحصر» تحت 0.5، ثم شغّل حتى الزمن 150 كاملًا وعُدَّ الأنوية التي بقيت.
## Intuition
diff --git a/content/lessons/nuclear/nuclear-fusion/en.md b/content/lessons/nuclear/nuclear-fusion/en.md
index e45a5614..33db0d33 100644
--- a/content/lessons/nuclear/nuclear-fusion/en.md
+++ b/content/lessons/nuclear/nuclear-fusion/en.md
@@ -26,7 +26,7 @@ charts: []
1. Keep "temperature" below 1 and "confinement" below 0.5, then run to time 80 or beyond. Fusion events should stay rare.
2. Raise "temperature" above 3 and "confinement" above 0.8, then run to time 80 or beyond. Several fusion events should appear.
-3. Run all the way to time 150 and count how many nuclei are still left.
+3. Raise "temperature" above 3 but lower "confinement" below 0.5, then run all the way to time 150 and count how many nuclei are still left.
## Intuition
diff --git a/content/lessons/nuclear/nuclear-fusion/lesson.yaml b/content/lessons/nuclear/nuclear-fusion/lesson.yaml
index a287b126..d0823b52 100644
--- a/content/lessons/nuclear/nuclear-fusion/lesson.yaml
+++ b/content/lessons/nuclear/nuclear-fusion/lesson.yaml
@@ -54,4 +54,4 @@ presets:
challenges:
- check: temperature < 1 and confinement < 0.5 and step >= 80
- check: temperature > 3 and confinement > 0.8 and step >= 80
- - check: step >= 150
+ - check: temperature > 3 and confinement < 0.5 and step >= 150
diff --git a/content/lessons/nuclear/radioactive-decay/ar.md b/content/lessons/nuclear/radioactive-decay/ar.md
index a3be33ed..b8747bf4 100644
--- a/content/lessons/nuclear/radioactive-decay/ar.md
+++ b/content/lessons/nuclear/radioactive-decay/ar.md
@@ -29,8 +29,8 @@ charts: []
## Test yourself
-1. قدِّم «الزمن» إلى عمر نصف واحد بالضبط.
-2. قدِّم «الزمن» حتى يبقى أقل من 5% من الذرات.
+1. ارفع «كم ذرة تبدأ بها» إلى 200 أو أكثر، ثم قدِّم «الزمن» إلى عمر نصف واحد بالضبط.
+2. اضبط عمر النصف على قيمة اليود-131، نحو 8 أيام (حين تقرأ «عمر النصف» القيمة 7.9 d)، ثم قدِّم «الزمن» حتى يبقى أقل من 5% من الذرات.
3. اضبط عمر النصف على قيمة الكربون-14، نحو 5730 سنة (أقرب ما يصل إليه المنزلق حين تقرأ «عمر النصف» القيمة 5462.7 yr)، ثم قدِّم «الزمن» إلى عمري نصف بالضبط.
## Intuition
diff --git a/content/lessons/nuclear/radioactive-decay/en.md b/content/lessons/nuclear/radioactive-decay/en.md
index ece81ce2..fe39e175 100644
--- a/content/lessons/nuclear/radioactive-decay/en.md
+++ b/content/lessons/nuclear/radioactive-decay/en.md
@@ -28,8 +28,8 @@ charts: []
## Test yourself
-1. Run "time" forward to exactly 1 half-life.
-2. Run "time" forward until fewer than 5% of the atoms remain.
+1. Raise "how many atoms" to 200 or more, then run "time" forward to exactly 1 half-life.
+2. Set the half-life to iodine-131's, about 8 days (the "half-life" readout shows 7.9 d), then run "time" forward until fewer than 5% of the atoms remain.
3. Set the half-life to carbon-14's, about 5730 years (the slider gets closest when the "half-life" readout shows 5462.7 yr), then run "time" forward to exactly 2 half-lives.
## Intuition
diff --git a/content/lessons/nuclear/radioactive-decay/lesson.yaml b/content/lessons/nuclear/radioactive-decay/lesson.yaml
index 51d2c62b..fbd5fc1c 100644
--- a/content/lessons/nuclear/radioactive-decay/lesson.yaml
+++ b/content/lessons/nuclear/radioactive-decay/lesson.yaml
@@ -57,6 +57,6 @@ presets:
time: 1
N0: 100
challenges:
- - check: abs(time - 1) < 0.05
- - check: (0.5)^time < 0.05
+ - check: N0 >= 200 and abs(time - 1) < 0.05
+ - check: abs(halfLife - 0.9) < 0.1 and (0.5)^time < 0.05
- check: abs(halfLife - 6.3207) < 0.1 and abs(time - 2) < 0.05
diff --git a/src/viz/nuclear/BindingEnergy.vue b/src/viz/nuclear/BindingEnergy.vue
index e484136d..f350175f 100644
--- a/src/viz/nuclear/BindingEnergy.vue
+++ b/src/viz/nuclear/BindingEnergy.vue
@@ -10,7 +10,10 @@ import Readouts from '../../components/Readouts.vue'
// Z(A) follows the standard beta-stability approximation Z = A / (2 + 0.015 A^(2/3)).
const A_V = 15.75, A_S = 17.8, A_C = 0.711, A_A = 23.7
const A_MIN = 2, A_MAX = 240
+// The smooth formula is one proton short for a few well-known nuclei (it has no pairing term): pin them.
+const KNOWN_Z: Record = { 20: 10, 56: 26, 60: 28, 235: 92 }
function stableZ(A: number): number {
+ if (KNOWN_Z[A]) return KNOWN_Z[A]
return Math.max(1, Math.min(A - 1, Math.round(A / (2 + 0.015 * Math.pow(A, 2 / 3)))))
}
function beOverA(A: number): number {
diff --git a/src/viz/nuclear/ChainReaction.vue b/src/viz/nuclear/ChainReaction.vue
index fe0ab61e..65edcc95 100644
--- a/src/viz/nuclear/ChainReaction.vue
+++ b/src/viz/nuclear/ChainReaction.vue
@@ -45,7 +45,8 @@ const tree = computed(() => {
const parents: number[] = []
for (let pi = 0; pi < prev.length && parents.length < CAP; pi++) {
let children = floorK
- if (rnd() < frac) children++
+ // below k = 1 the single lineage lasts while k^g still rounds to 1, so it fades as k^g does
+ if (floorK === 0 ? k.value ** g >= 0.5 : rnd() < frac) children++
for (let c = 0; c < children && parents.length < CAP; c++) parents.push(pi)
}
const y = Y0 + rowH * g
diff --git a/src/viz3d/nuclear/BindingEnergy3D.vue b/src/viz3d/nuclear/BindingEnergy3D.vue
index 76ca0282..4419b416 100644
--- a/src/viz3d/nuclear/BindingEnergy3D.vue
+++ b/src/viz3d/nuclear/BindingEnergy3D.vue
@@ -21,7 +21,10 @@ const R0 = 1.2 // fm
const SCALE = 0.34 // scene units per fm
const GOLDEN = Math.PI * (3 - Math.sqrt(5))
+// The smooth formula is one proton short for a few well-known nuclei (it has no pairing term): pin them.
+const KNOWN_Z: Record = { 20: 10, 56: 26, 60: 28, 235: 92 }
function stableZ(A: number): number {
+ if (KNOWN_Z[A]) return KNOWN_Z[A]
return Math.max(1, Math.min(A - 1, Math.round(A / (2 + 0.015 * Math.pow(A, 2 / 3)))))
}
function beOverA(A: number): number {
diff --git a/src/viz3d/nuclear/ChainReaction3D.vue b/src/viz3d/nuclear/ChainReaction3D.vue
index bff2b4f6..82cd92a6 100644
--- a/src/viz3d/nuclear/ChainReaction3D.vue
+++ b/src/viz3d/nuclear/ChainReaction3D.vue
@@ -33,7 +33,7 @@ function countPopulation(k: number, generations: number) {
let next = 0
for (let pi = 0; pi < n && next < CAP; pi++) {
let children = floorK
- if (rnd() < frac) children++
+ if (floorK === 0 ? k ** g >= 0.5 : rnd() < frac) children++
next += children
}
n = next
From 9c0dbf1d1d1cf1417b0ed87506f5a3c07df606ba Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 04/10] fix: mutation strip, seasons tilt and action-potential
notes
---
content/lessons/biology/action-potential/ar.md | 2 +-
content/lessons/biology/action-potential/en.md | 2 +-
content/lessons/biology/dna-and-mutation-rates/ar.md | 6 +++---
content/lessons/biology/dna-and-mutation-rates/en.md | 6 +++---
content/lessons/earth-space/seasons/ar.md | 2 +-
content/lessons/earth-space/seasons/en.md | 2 +-
content/lessons/earth-space/seasons/lesson.yaml | 2 +-
content/ui/ar/mutation.yaml | 2 +-
content/ui/en/mutation.yaml | 2 +-
src/viz/biology/Mutation.vue | 9 +++++----
10 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/content/lessons/biology/action-potential/ar.md b/content/lessons/biology/action-potential/ar.md
index b93eb7ba..163be1d2 100644
--- a/content/lessons/biology/action-potential/ar.md
+++ b/content/lessons/biology/action-potential/ar.md
@@ -31,7 +31,7 @@ variables:
## Test yourself
-1. اجعل تيار المنبّه $I$ فوق 1.0 ولا يزيد على 1.4، لتطلق الخلية شرارة بعد شرارة.
+1. اجعل تيار المنبّه $I$ فوق 1.0 ولا يزيد على 1.4، لتطلق الخلية شرارة بعد شرارة. (إذا رفعت $I$ إلى 1.45 أو أكثر تخفت الشرارات: يبقى الجهد عالقًا في الأعلى، لأن المنبّه القوي جدًا لا يترك الخلية تستعيد حالتها.)
2. اجعل إعدادَي التعافي $a$ و$b$ متساويين.
3. أبطئ التعافي إلى أقصاه $\tau = 20$ مع إبقاء تيار المنبّه عند 0.1 أو أقل، لتبقى الخلية ساكنة.
diff --git a/content/lessons/biology/action-potential/en.md b/content/lessons/biology/action-potential/en.md
index 9d7c942f..cbccd091 100644
--- a/content/lessons/biology/action-potential/en.md
+++ b/content/lessons/biology/action-potential/en.md
@@ -35,7 +35,7 @@ variables:
## Test yourself
-1. Set the stimulus current $I$ above 1.0 but no higher than 1.4, so the neuron keeps firing spike after spike.
+1. Set the stimulus current $I$ above 1.0 but no higher than 1.4, so the neuron keeps firing spike after spike. (Push $I$ to 1.45 or more and the spikes die away: the voltage stays stuck high, because a stimulus that is too strong never lets the cell recover.)
2. Set the two recovery settings, $a$ and $b$, to the same number.
3. Slow the recovery all the way to $\tau = 20$ while keeping the stimulus current at 0.1 or below, so the neuron stays quiet.
diff --git a/content/lessons/biology/dna-and-mutation-rates/ar.md b/content/lessons/biology/dna-and-mutation-rates/ar.md
index b8d42df1..908a0e0b 100644
--- a/content/lessons/biology/dna-and-mutation-rates/ar.md
+++ b/content/lessons/biology/dna-and-mutation-rates/ar.md
@@ -16,13 +16,13 @@ variables:
## Try it
1. ابدأ بمعدل بطيء يشبه معدل الإنسان (μ = 0.01)، وبـ10 أجيال فقط. لا يتغيّر شيء تقريبًا: الطفرات المتوقعة E تساوي 0 ولا مربع أحمر.
-2. اجعل المعدل μ = 1 وارفع عدد الأجيال إلى 1000. يرتفع E ببطء إلى 1: نحو قاعدة واحدة متغيّرة في التسلسل كله (1000 قاعدة)، وهذا أقل من أن يظهر في نافذة الـ60 مربعًا.
-3. بدّل إلى معدل سريع يشبه الفيروسات، μ = 100. يقفز E إلى 100، ويتغيّر 10% من القواعد، ويحمرّ 6 مربعات من الـ60.
+2. اجعل المعدل μ = 1 وارفع عدد الأجيال إلى 1000. يرتفع E ببطء إلى 1: نحو قاعدة واحدة متغيّرة في التسلسل كله (1000 قاعدة)، ويحمرّ مربع واحد من الـ60.
+3. بدّل إلى معدل سريع يشبه الفيروسات، μ = 100. يقفز E إلى 100، ويتغيّر 10% من القواعد، ويحمرّ 47 مربعًا من الـ60: صار في كل قطعة من التسلسل تقريبًا قاعدة تغيّرت.
## Real-life examples
1. **جين بشري يُنسخ عبر 10 أجيال.** بمعدل خطأ واحد تقريبًا لكل مئة مليون قاعدة، لا يتغيّر شيء عمليًا. يُنسخ الحمض النووي البشري بعناية فائقة.
-2. **بكتيريا E. coli تتطور في المختبر عبر 1000 جيل.** تجربة حقيقية (تجربة لينسكي، ما زالت مستمرة بعد عشرات آلاف الأجيال): تنقسم البكتيريا بسرعة كبيرة، عدة أجيال في اليوم، فيظهر تغيّر حقيقي خلال مدة التجربة في المختبر.
+2. **بكتيريا E. coli تتطور في المختبر عبر 1000 جيل.** تجربة حقيقية (تجربة لينسكي، ما زالت مستمرة بعد عشرات آلاف الأجيال): تنقسم البكتيريا بسرعة كبيرة، عدة أجيال في اليوم، فيظهر تغيّر حقيقي خلال مدة التجربة في المختبر. المعدل في هذا المثال (μ = 0.5) أعلى بكثير من معدل E. coli الحقيقي، فالمعدل الحقيقي أصغر من أن يصل إليه المنزلق، وقد رُفع ليظهر التغيّر في الرسم.
3. **قطعة جين إنفلونزا عبر موسم واحد، نحو 50 دورة تضاعف.** آلة نسخ الإنفلونزا أكثر عرضة للخطأ بكثير، فتظهر سلالات جديدة خلال موسم واحد، ولهذا يُحدَّث لقاح الإنفلونزا كل عام.
## Test yourself
diff --git a/content/lessons/biology/dna-and-mutation-rates/en.md b/content/lessons/biology/dna-and-mutation-rates/en.md
index a9c84dfd..4f9c1516 100644
--- a/content/lessons/biology/dna-and-mutation-rates/en.md
+++ b/content/lessons/biology/dna-and-mutation-rates/en.md
@@ -19,13 +19,13 @@ variables:
## Try it
1. Start with a slow, human-like rate (μ = 0.01) and only 10 generations — almost nothing changes: expected mutations E reads 0 and no box is red.
-2. Set the rate to μ = 1 and push generations up to 1000. E climbs slowly to 1: about one changed base in the whole 1000-base sequence, still too few to show in the 60-box window.
-3. Switch to a fast, virus-like rate, μ = 100. E jumps to 100, 10% of the bases have changed, and 6 of the 60 boxes turn red.
+2. Set the rate to μ = 1 and push generations up to 1000. E climbs slowly to 1: about one changed base in the whole 1000-base sequence, and one of the 60 boxes turns red.
+3. Switch to a fast, virus-like rate, μ = 100. E jumps to 100, 10% of the bases have changed, and 47 of the 60 boxes turn red: almost every slice of the sequence now holds a changed base.
## Real-life examples
1. **A human gene copied across 10 generations.** At about one mistake per hundred million bases, essentially nothing changes — human DNA is copied with extraordinary care.
-2. **E. coli evolving in the lab for 1000 generations.** A real experiment (Lenski's, still running after tens of thousands of generations): bacteria divide so fast — several generations a day — that real change shows up on a lab timescale.
+2. **E. coli evolving in the lab for 1000 generations.** A real experiment (Lenski's, still running after tens of thousands of generations): bacteria divide so fast — several generations a day — that real change shows up on a lab timescale. The rate in this example (μ = 0.5) is set far above the real E. coli rate, which is too small for the slider, so that the change shows in the picture.
3. **A flu gene segment over one flu season, about 50 replication cycles.** Influenza's copying machinery makes far more mistakes per copy — new variants appear within a single season, which is why flu vaccines are updated every year.
## Test yourself
diff --git a/content/lessons/earth-space/seasons/ar.md b/content/lessons/earth-space/seasons/ar.md
index e2a01d09..c9568cd3 100644
--- a/content/lessons/earth-space/seasons/ar.md
+++ b/content/lessons/earth-space/seasons/ar.md
@@ -5,7 +5,7 @@ summary: >-
parameters:
lat: خط العرض
x: يوم السنة
- tilt: ميل المحور (يستخدمه العرض ثلاثي الأبعاد)
+ tilt: ميل المحور
variables:
- خط العرض الذي تقف عنده
- ميل الشمس، أي بُعدها شمالًا أو جنوبًا عن خط الاستواء عند الظهيرة
diff --git a/content/lessons/earth-space/seasons/en.md b/content/lessons/earth-space/seasons/en.md
index 06ae6f7e..738dce76 100644
--- a/content/lessons/earth-space/seasons/en.md
+++ b/content/lessons/earth-space/seasons/en.md
@@ -6,7 +6,7 @@ summary: >-
parameters:
lat: latitude
x: day of year
- tilt: axial tilt (used by the 3D view)
+ tilt: axial tilt
variables:
- the latitude where you are standing
- the Sun's declination — how far north or south of the equator it sits overhead
diff --git a/content/lessons/earth-space/seasons/lesson.yaml b/content/lessons/earth-space/seasons/lesson.yaml
index b4177a1a..9a2ccfe9 100644
--- a/content/lessons/earth-space/seasons/lesson.yaml
+++ b/content/lessons/earth-space/seasons/lesson.yaml
@@ -13,7 +13,7 @@ related:
visualization:
type: function-plot
options:
- expr: 24/pi*acos(max(-1,min(1,-tan(lat*pi/180)*tan(23.4*pi/180*sin(2*pi*(x-80)/365)))))
+ expr: 24/pi*acos(max(-1,min(1,-tan(lat*pi/180)*tan(tilt*pi/180*sin(2*pi*(x-80)/365)))))
domain: [0, 365]
range: [0, 24]
mode: plain
diff --git a/content/ui/ar/mutation.yaml b/content/ui/ar/mutation.yaml
index d227387f..b089de27 100644
--- a/content/ui/ar/mutation.yaml
+++ b/content/ui/ar/mutation.yaml
@@ -1,5 +1,5 @@
mut.hint: اسحب طول التسلسل، ومعدل الطفرات، وعدد الأجيال
-mut.strip: نافذة من 60 قاعدة من التسلسل — المربعات الحمراء تغيّرت
+mut.strip: التسلسل كله في 60 قطعة — المربع الأحمر فيه قاعدة تغيّرت
mut.n: طول التسلسل N
mut.mu: معدل الطفرات μ
mut.g: عدد الأجيال g
diff --git a/content/ui/en/mutation.yaml b/content/ui/en/mutation.yaml
index b0057c0c..8f3140b4 100644
--- a/content/ui/en/mutation.yaml
+++ b/content/ui/en/mutation.yaml
@@ -1,5 +1,5 @@
mut.hint: drag the sequence length, mutation rate and generations
-mut.strip: a 60-base window of the sequence — red boxes have changed
+mut.strip: the whole sequence in 60 slices — a red box holds a changed base
mut.n: sequence length N
mut.mu: mutation rate μ
mut.g: generations g
diff --git a/src/viz/biology/Mutation.vue b/src/viz/biology/Mutation.vue
index 3722711c..21ecaa4c 100644
--- a/src/viz/biology/Mutation.vue
+++ b/src/viz/biology/Mutation.vue
@@ -19,18 +19,19 @@ const g = computed(() => Math.max(0, props.params.g ?? 100))
const fracMutated = computed(() => Math.min(1, muTrue.value * g.value))
const E = computed(() => N.value * muTrue.value * g.value)
-// A 60-base strip. Each box's random threshold is fixed once, so raising the mutation fraction
+// The whole sequence cut into 60 slices; a slice is red once it holds at least one changed base
+// (chance 1 - e^(-E/60)). Each box's random threshold is fixed once, so raising the mutation fraction
// lights up more boxes without the already-mutated ones flickering to a new random spot.
const N_BOXES = 60
let seed = 42
const rand = () => { seed = (seed * 1103515245 + 12345) & 0x7fffffff; return seed / 0x7fffffff }
const thresholds = Array.from({ length: N_BOXES }, () => rand())
-const boxes = computed(() => thresholds.map((th) => th < fracMutated.value))
+const boxes = computed(() => thresholds.map((th) => th < 1 - Math.exp(-E.value / N_BOXES)))
const stripX = 40
const stripY = 90
-const boxW = 11
-const boxGap = 2.2
+const boxW = 5.5
+const boxGap = 1.1
// Accumulation line: E(x) = N·μ·x for x in [0, g], scaled to fit the panel.
const chartX = [460, 760] as const
From 903fbe8278f0cffa7ff5afb85b7844f99b860164 Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 05/10] feat: logarithmic parameter sliders, used by the
decibels lesson
---
content/lessons/engineering/decibels/lesson.yaml | 3 ++-
scripts/content/build.ts | 2 +-
scripts/content/schema.ts | 2 +-
src/components/ParamSlider.vue | 15 +++++++++------
src/lessons/types.ts | 2 ++
src/pages/LessonView.vue | 2 +-
6 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/content/lessons/engineering/decibels/lesson.yaml b/content/lessons/engineering/decibels/lesson.yaml
index 5ba3e74d..2cf6c507 100644
--- a/content/lessons/engineering/decibels/lesson.yaml
+++ b/content/lessons/engineering/decibels/lesson.yaml
@@ -16,8 +16,9 @@ parameters:
x:
min: 1
max: 1000000
- step: 1000
+ step: 1
value: 1000
+ scale: log
variables:
- L
- P
diff --git a/scripts/content/build.ts b/scripts/content/build.ts
index 207f8b9b..8db9b719 100644
--- a/scripts/content/build.ts
+++ b/scripts/content/build.ts
@@ -109,7 +109,7 @@ for (const subject of readdirSync(join(CONTENT, 'lessons')).sort((a, b) => order
try { code = compile(ch.check) } catch (e: any) { return err(`${where}/lesson.yaml`, `challenges[${i}].check: ${String(e.message).slice(0, 80)}`) }
const names = Object.keys(L.parameters)
const passes = (sc: Record) => { try { const v = code.evaluate(sc); if (ch.target === undefined) return !!v; const tol = ch.tol ?? Math.max(0.01, Math.abs(ch.target) * 0.02); return typeof v === 'number' && Math.abs(v - ch.target) <= tol } catch { return false } }
- const snap = (k: string, v: number) => { const p = L.parameters[k]; return Math.min(p.max, Math.max(p.min, p.min + Math.round((v - p.min) / p.step) * p.step)) }
+ const snap = (k: string, v: number) => { const p = L.parameters[k]; if (p.scale === 'log') return Math.min(p.max, Math.max(p.min, +v.toPrecision(2))); return Math.min(p.max, Math.max(p.min, p.min + Math.round((v - p.min) / p.step) * p.step)) }
let ok = false
// Deterministic search (a seeded generator, so CI never flakes). Tight tasks usually pin some
// sliders to "likely" values: the default, preset values and the numbers written in the check.
diff --git a/scripts/content/schema.ts b/scripts/content/schema.ts
index 9457d83d..1c28fec9 100644
--- a/scripts/content/schema.ts
+++ b/scripts/content/schema.ts
@@ -34,7 +34,7 @@ export const SUBJECTS = [
] as const
export const LEVELS = ['beginner', 'high-school', 'university', 'advanced'] as const
-export const ParamSpec = z.object({ min: z.number(), max: z.number(), step: z.number().positive(), value: z.number(), unit: z.string().optional() })
+export const ParamSpec = z.object({ min: z.number(), max: z.number(), step: z.number().positive(), value: z.number(), unit: z.string().optional(), scale: z.enum(['log']).optional() })
export const Video = z.object({ title: z.string(), url: z.string().url(), by: z.string(), lang: z.string(), note: z.string().optional() })
diff --git a/src/components/ParamSlider.vue b/src/components/ParamSlider.vue
index fe21d7ef..a1eeb452 100644
--- a/src/components/ParamSlider.vue
+++ b/src/components/ParamSlider.vue
@@ -5,7 +5,10 @@ import { fmt } from '../engine/math'
const props = defineProps<{ name: string; spec: ParamSpec; value: number }>()
defineEmits<{ set: [name: string, value: number] }>()
-const pct = computed(() => `${((props.value - props.spec.min) / (props.spec.max - props.spec.min)) * 100}%`)
+// a 'log' slider moves along log10 of the value, so every ×10 takes the same distance
+const log = computed(() => props.spec.scale === 'log')
+const pos = (v: number) => (log.value ? Math.log10(v) : v)
+const pct = computed(() => `${((pos(props.value) - pos(props.spec.min)) / (pos(props.spec.max) - pos(props.spec.min))) * 100}%`)
@@ -20,12 +23,12 @@ const pct = computed(() => `${((props.value - props.spec.min) / (props.spec.max
type="range"
class="mt-1 w-full"
:style="{ '--p': pct }"
- :min="spec.min"
- :max="spec.max"
- :step="spec.step"
- :value="value"
+ :min="pos(spec.min)"
+ :max="pos(spec.max)"
+ :step="log ? 0.005 : spec.step"
+ :value="pos(value)"
:aria-label="spec.label"
- @input="$emit('set', name, +($event.target as HTMLInputElement).value)"
+ @input="$emit('set', name, log ? 10 ** +($event.target as HTMLInputElement).value : +($event.target as HTMLInputElement).value)"
/>
diff --git a/src/lessons/types.ts b/src/lessons/types.ts
index d346b8e5..b6242ed2 100644
--- a/src/lessons/types.ts
+++ b/src/lessons/types.ts
@@ -44,6 +44,8 @@ export interface ParamSpec {
step: number
value: number
unit?: string
+ /** 'log': the slider moves in equal ×10 steps and values are rounded to 2 significant figures (`step` is not used). */
+ scale?: 'log'
}
export interface ChartSpec {
diff --git a/src/pages/LessonView.vue b/src/pages/LessonView.vue
index 0df131f8..90cf1351 100644
--- a/src/pages/LessonView.vue
+++ b/src/pages/LessonView.vue
@@ -97,7 +97,7 @@ function loadPreset(values: Record) {
function setParam(name: string, value: number) {
const spec = base.value?.parameters[name]
if (!spec) return
- const snapped = Math.round(value / spec.step) * spec.step
+ const snapped = spec.scale === 'log' ? +value.toPrecision(2) : Math.round(value / spec.step) * spec.step
params[name] = Math.min(spec.max, Math.max(spec.min, +snapped.toFixed(6)))
}
From 204d32c1f40433da1ce883c71dc2c1cb2b1e7143 Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 06/10] fix: translate PID plot labels
---
content/lessons/engineering/pid-control/lesson.yaml | 6 +++---
content/ui/ar/pid-control.yaml | 2 ++
content/ui/en/pid-control.yaml | 2 ++
src/viz/shared/OdeSystem.vue | 5 +++--
4 files changed, 10 insertions(+), 5 deletions(-)
create mode 100644 content/ui/ar/pid-control.yaml
create mode 100644 content/ui/en/pid-control.yaml
diff --git a/content/lessons/engineering/pid-control/lesson.yaml b/content/lessons/engineering/pid-control/lesson.yaml
index 25c2431e..9e27a48f 100644
--- a/content/lessons/engineering/pid-control/lesson.yaml
+++ b/content/lessons/engineering/pid-control/lesson.yaml
@@ -25,9 +25,9 @@ visualization:
- '0'
- '0'
tMax: 30
- labels:
- - temperature x
- - integral I
+ labelKeys:
+ - pid.x
+ - pid.i
parameters:
Kp:
min: 0
diff --git a/content/ui/ar/pid-control.yaml b/content/ui/ar/pid-control.yaml
new file mode 100644
index 00000000..3a582cf7
--- /dev/null
+++ b/content/ui/ar/pid-control.yaml
@@ -0,0 +1,2 @@
+pid.x: الحرارة x
+pid.i: الخطأ المتراكم I
diff --git a/content/ui/en/pid-control.yaml b/content/ui/en/pid-control.yaml
new file mode 100644
index 00000000..fd2a82e3
--- /dev/null
+++ b/content/ui/en/pid-control.yaml
@@ -0,0 +1,2 @@
+pid.x: temperature x
+pid.i: integral I
diff --git a/src/viz/shared/OdeSystem.vue b/src/viz/shared/OdeSystem.vue
index ed0fcc84..4201b6d0 100644
--- a/src/viz/shared/OdeSystem.vue
+++ b/src/viz/shared/OdeSystem.vue
@@ -8,7 +8,7 @@ import Readouts from '../../components/Readouts.vue'
/**
* Integrates any system dY/dt = F(Y, t, params) with classical RK4 and plots every variable.
* options: { vars: ['S','I','R'], equations: ['-b*S*I/N', ...] (mathjs, may use vars, t and params),
- * initial: ['N - I0', 'I0', '0'] (expressions in params), tMax, yMax?, labels?: string[], colors?: string[] }
+ * initial: ['N - I0', 'I0', '0'] (expressions in params), tMax, yMax?, labels?: string[], labelKeys?: string[], colors?: string[] }
* The param `tView` (0..1) scrubs the marker along the curves. Rerun happens automatically when params change.
*/
const props = defineProps<{ params: Record; options: Record }>()
@@ -20,7 +20,8 @@ const PAD = { l: 56, r: 24, t: 24, b: 40 }
const vars = computed(() => props.options.vars)
const palette = ['var(--accent)', 'var(--neg)', 'var(--pos)', 'var(--accent-2)', 'var(--fg)']
const colors = computed(() => props.options.colors ?? palette)
-const labels = computed(() => props.options.labels ?? vars.value)
+// labelKeys (UI string keys) give translated labels; plain `labels` are shown as written
+const labels = computed(() => (props.options.labelKeys as string[] | undefined)?.map((k) => t(k as any)) ?? props.options.labels ?? vars.value)
const fns = computed(() => (props.options.equations as string[]).map((e) => compile(e)))
const inits = computed(() => (props.options.initial as string[]).map((e) => compile(e)))
From 329fe9250300223a4bd6c17c12eb34fc7699bf60 Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 07/10] fix: aerodynamics visualizations match their lessons
---
content/lessons/aerodynamics/bernoulli/lesson.yaml | 4 ++--
.../aerodynamics/gliding-and-glide-ratio/ar.md | 2 +-
.../aerodynamics/gliding-and-glide-ratio/en.md | 2 +-
.../aerodynamics/gliding-and-glide-ratio/lesson.yaml | 2 +-
.../aerodynamics/helicopters-and-rotors/ar.md | 8 ++++----
.../aerodynamics/helicopters-and-rotors/en.md | 8 ++++----
.../aerodynamics/helicopters-and-rotors/lesson.yaml | 12 ++++++------
.../lessons/aerodynamics/propellers-and-jets/ar.md | 4 ++--
.../lessons/aerodynamics/propellers-and-jets/en.md | 4 ++--
.../aerodynamics/propellers-and-jets/lesson.yaml | 2 +-
content/ui/ar/helicopters-and-rotors.yaml | 1 +
content/ui/en/helicopters-and-rotors.yaml | 1 +
src/viz/aerodynamics/HelicoptersAndRotors.vue | 6 +++---
.../aerodynamics/WingtipVorticesAndInducedDrag.vue | 3 ++-
src/viz3d/aerodynamics/HelicoptersAndRotors3D.vue | 4 ++--
15 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/content/lessons/aerodynamics/bernoulli/lesson.yaml b/content/lessons/aerodynamics/bernoulli/lesson.yaml
index 55ccb08c..9a14479f 100644
--- a/content/lessons/aerodynamics/bernoulli/lesson.yaml
+++ b/content/lessons/aerodynamics/bernoulli/lesson.yaml
@@ -52,7 +52,7 @@ challenges:
- check: 'v1/ratio'
target: 20
tol: 2
- - check: '0.6125*v1^2*(1/ratio^2-1)'
+ - check: '0.6*v1^2*(1/ratio^2-1)'
target: 500
tol: 50
- - check: 'v1/ratio < 15 and 0.6125*v1^2*(1/ratio^2-1) > 100'
+ - check: 'v1/ratio < 15 and 0.6*v1^2*(1/ratio^2-1) > 100'
diff --git a/content/lessons/aerodynamics/gliding-and-glide-ratio/ar.md b/content/lessons/aerodynamics/gliding-and-glide-ratio/ar.md
index 54652dbc..1a7217e5 100644
--- a/content/lessons/aerodynamics/gliding-and-glide-ratio/ar.md
+++ b/content/lessons/aerodynamics/gliding-and-glide-ratio/ar.md
@@ -19,7 +19,7 @@ variables:
## Real-life examples
-1. **طائرة من الورق تُرمى من فوق مكتب.** أُطلقت من ارتفاع 1.5 m بنسبة انزلاق نحو 4. تقطع نحو 6 أمتار قبل أن تلامس الأرض: انزلاق قصير شديد الانحدار.
+1. **طائرة من الورق تُرمى من فوق مكتب.** أُطلقت من ارتفاع 1 m بنسبة انزلاق نحو 4. تقطع نحو 4 أمتار قبل أن تلامس الأرض: انزلاق قصير شديد الانحدار.
2. **طائرة شراعية أُطلقت من ارتفاع 1000 m.** بنسبة انزلاق نحو 30، تستطيع قطع نحو 30 كم قبل الهبوط. يعتمد التحليق الشراعي عبر المسافات على هذا الرقم بالضبط.
3. **طائرة عريضة الجسم فقدت محركيها من ارتفاع 12500 m.** بنسبة انزلاق نحو 15، تستطيع نظريًا قطع 187 كم في خط مستقيم. حالات انزلاق حقيقية مشهورة بعد فقدان المحرك قطعت مسافة أقل قليلًا، لأن الطاقم اضطر أيضًا للمناورة والتخلص من ارتفاع زائد قبل الهبوط.
diff --git a/content/lessons/aerodynamics/gliding-and-glide-ratio/en.md b/content/lessons/aerodynamics/gliding-and-glide-ratio/en.md
index a5277a3c..67302696 100644
--- a/content/lessons/aerodynamics/gliding-and-glide-ratio/en.md
+++ b/content/lessons/aerodynamics/gliding-and-glide-ratio/en.md
@@ -21,7 +21,7 @@ variables:
## Real-life examples
-1. **A paper aeroplane from a desk.** Released 1.5 m up with a glide ratio around 4, it covers roughly 6 m before touching down — a steep, short glide.
+1. **A paper aeroplane from a desk.** Released 1 m up with a glide ratio around 4, it covers roughly 4 m before touching down — a steep, short glide.
2. **A sailplane released at 1,000 m.** With a glide ratio of about 30, it can cover roughly 30 km before landing — cross-country soaring depends on exactly this number.
3. **A widebody jet with both engines out, from 12,500 m.** At a clean glide ratio of about 15, it could in theory cover a straight-line 187 km — famous real engine-out glides have covered somewhat less, because the crew also had to manoeuvre to lose extra height before landing.
diff --git a/content/lessons/aerodynamics/gliding-and-glide-ratio/lesson.yaml b/content/lessons/aerodynamics/gliding-and-glide-ratio/lesson.yaml
index f3b70571..f445fcd0 100644
--- a/content/lessons/aerodynamics/gliding-and-glide-ratio/lesson.yaml
+++ b/content/lessons/aerodynamics/gliding-and-glide-ratio/lesson.yaml
@@ -39,7 +39,7 @@ derivation:
charts: []
presets:
- LD: 4
- h: 1.5
+ h: 1
- LD: 30
h: 1000
- LD: 15
diff --git a/content/lessons/aerodynamics/helicopters-and-rotors/ar.md b/content/lessons/aerodynamics/helicopters-and-rotors/ar.md
index 1bd794db..b666a74f 100644
--- a/content/lessons/aerodynamics/helicopters-and-rotors/ar.md
+++ b/content/lessons/aerodynamics/helicopters-and-rotors/ar.md
@@ -15,13 +15,13 @@ variables:
## Try it
-1. ابدأ بالقيم الظاهرة: هليكوبتر خفيفة، «نصف قطر الدوّار R» يساوي 3.84 m و«وزن الطائرة W» يساوي 6076 N. تحلّق ثابتة و«ميل الدوّار» عند 0°.
-2. اقرأ سرعة تيار الهواء الهابط v_i = 7.32 m/s وقدرة التحليق الثابت P = 44.5 kW. كلاهما تقدير، لكنه واقعي.
-3. اسحب «ميل الدوّار» إلى الأمام حتى 12°. يصعد الدفع الكلي T من 6076 N إلى 6212 N. القرص كله، لا جسم الطائرة، يميل ليدفع الطائرة إلى الأمام.
+1. ابدأ بالقيم الظاهرة: هليكوبتر خفيفة، «نصف قطر الدوّار R» يساوي 3.8 m و«وزن الطائرة W» يساوي 6075 N. تحلّق ثابتة و«ميل الدوّار» عند 0°.
+2. اقرأ سرعة تيار الهواء الهابط v_i = 7.39 m/s وقدرة التحليق الثابت P = 44.9 kW. كلاهما تقدير، لكنه واقعي.
+3. اسحب «ميل الدوّار» إلى الأمام حتى 12°. يصعد الدفع الكلي T من 6075 N إلى 6211 N. القرص كله، لا جسم الطائرة، يميل ليدفع الطائرة إلى الأمام.
## Real-life examples
-1. **هليكوبتر خفيفة تحلّق ثابتة.** دوّار نصف قطره 3.84 m يرفع 6076 N. يدفع الهواء إلى الأسفل بنحو 7.3 m/s، ويحتاج نحو 44 kW من القدرة المثالية للتحليق الثابت. محرك هليكوبتر حقيقية يغطي أيضًا خسائر يتجاهلها هذا التقدير.
+1. **هليكوبتر خفيفة تحلّق ثابتة.** دوّار نصف قطره 3.8 m يرفع 6075 N. يدفع الهواء إلى الأسفل بنحو 7.4 m/s، ويحتاج نحو 45 kW من القدرة المثالية للتحليق الثابت. محرك هليكوبتر حقيقية يغطي أيضًا خسائر يتجاهلها هذا التقدير.
2. **هليكوبتر رفع ثقيل تحلّق ثابتة.** دوّار نصف قطره 16 m يرفع نحو 550000 N. ما زال يدفع الهواء بنحو 16.7 m/s فقط، أكثر بقليل من ضعف تيار الهواء الهابط للهليكوبتر الخفيفة، رغم أنها ترفع وزنًا يقارب 100 ضعف، لأن قرصها أكبر بكثير.
3. **الهليكوبتر الخفيفة تميل للأمام لتطير بسرعة.** أمِل الدوّار نفسه 12° للأمام. ليستمر بحمل الوزن نفسه، يجب أن يرتفع الدفع الكلي بنحو 2%، تكلفة إضافية صغيرة لكنها حقيقية للطيران بسرعة.
diff --git a/content/lessons/aerodynamics/helicopters-and-rotors/en.md b/content/lessons/aerodynamics/helicopters-and-rotors/en.md
index 9c31d921..cf214291 100644
--- a/content/lessons/aerodynamics/helicopters-and-rotors/en.md
+++ b/content/lessons/aerodynamics/helicopters-and-rotors/en.md
@@ -17,13 +17,13 @@ variables:
## Try it
-1. Start with the values on screen: a small helicopter, «rotor radius R» 3.84 m, «aircraft weight W» 6,076 N, hovering with «rotor tilt» at 0°.
-2. Read the downwash speed v_i = 7.32 m/s and the hover power P = 44.5 kW — both are estimates, but realistic ones.
-3. Drag «rotor tilt» forward to 12°. Total thrust T climbs from 6076 N to 6212 N, and the whole disc — not the fuselage — leans to push the aircraft ahead.
+1. Start with the values on screen: a small helicopter, «rotor radius R» 3.8 m, «aircraft weight W» 6,075 N, hovering with «rotor tilt» at 0°.
+2. Read the downwash speed v_i = 7.39 m/s and the hover power P = 44.9 kW — both are estimates, but realistic ones.
+3. Drag «rotor tilt» forward to 12°. Total thrust T climbs from 6075 N to 6211 N, and the whole disc — not the fuselage — leans to push the aircraft ahead.
## Real-life examples
-1. **A light helicopter hovering.** A 3.84 m rotor lifting 6,076 N pushes air down at roughly 7.3 m/s and needs on the order of 44 kW of ideal power to hover — a real light helicopter's engine also has to cover losses this estimate ignores.
+1. **A light helicopter hovering.** A 3.8 m rotor lifting 6,075 N pushes air down at roughly 7.4 m/s and needs on the order of 45 kW of ideal power to hover — a real light helicopter's engine also has to cover losses this estimate ignores.
2. **A heavy-lift helicopter hovering.** A 16 m rotor lifting nearly 550,000 N still only pushes air down at about 16.7 m/s — barely more than twice the light helicopter's downwash, despite lifting almost 100 times the weight, because its disc is so much bigger.
3. **The light helicopter tilted forward for cruise.** Tilt the same rotor 12° forward and, to keep supporting the same weight, total thrust has to rise by about 2% — a small but real extra cost of flying fast.
diff --git a/content/lessons/aerodynamics/helicopters-and-rotors/lesson.yaml b/content/lessons/aerodynamics/helicopters-and-rotors/lesson.yaml
index 5cbfd4ad..6914be73 100644
--- a/content/lessons/aerodynamics/helicopters-and-rotors/lesson.yaml
+++ b/content/lessons/aerodynamics/helicopters-and-rotors/lesson.yaml
@@ -23,13 +23,13 @@ parameters:
min: 0.3
max: 16
step: 0.1
- value: 3.84
+ value: 3.8
unit: m
W:
min: 5
max: 600000
step: 5
- value: 6076
+ value: 6075
unit: N
tilt:
min: -15
@@ -48,14 +48,14 @@ derivation:
- P = T\, v_i
charts: []
presets:
- - R: 3.84
- W: 6076
+ - R: 3.8
+ W: 6075
tilt: 0
- R: 16
W: 548800
tilt: 0
- - R: 3.84
- W: 6076
+ - R: 3.8
+ W: 6075
tilt: 12
challenges:
- check: 'sqrt((W/cos(tilt*pi/180))/(2*1.225*pi*R^2))'
diff --git a/content/lessons/aerodynamics/propellers-and-jets/ar.md b/content/lessons/aerodynamics/propellers-and-jets/ar.md
index 69375649..e2e62ea1 100644
--- a/content/lessons/aerodynamics/propellers-and-jets/ar.md
+++ b/content/lessons/aerodynamics/propellers-and-jets/ar.md
@@ -38,7 +38,7 @@ variables:
## Formal
-الدفع بحسب نظرية الزخم هو $T = \dot m\, \Delta v$، حيث معدل التدفق الكتلي عبر قرص الدفع هو $\dot m = \rho A v$، أي الكثافة مضروبة في مساحة القرص وسرعة الهواء عبره.
+الدفع بحسب نظرية الزخم هو $T = \dot m\, \Delta v$، حيث معدل التدفق الكتلي عبر قرص الدفع هو $\dot m = \rho A \left(v + \tfrac{\Delta v}{2}\right)$، أي الكثافة مضروبة في مساحة القرص وسرعة الهواء عبره. هذه السرعة تقع في منتصف المسافة بين سرعة الهواء الداخل $v$ وسرعة العادم $v + \Delta v$.
كفاءة الدفع المثالية هي قدرة الدفع المفيدة مقسومة على إجمالي القدرة الحركية المضافة إلى الهواء. تعطي هذه النسبة $\eta = \dfrac{2v}{2v + \Delta v}$. تنخفض نحو الصفر كلما كبرت $\Delta v$ بالنسبة لسرعة الطيران $v$، وترتفع نحو 100% كلما اقتربت $\Delta v \to 0$. لكن الدفع نفسه سينخفض حينها نحو الصفر أيضًا، فتوازن التصاميم الحقيقية بين الاثنين.
@@ -48,7 +48,7 @@ variables:
## Derivation
-1. يسرّع المحرك كل ثانية كتلة هواء $\dot m = \rho A v$، أي الكثافة مضروبة في مساحة القرص وسرعة الهواء المتحرك عبره، بمقدار $\Delta v$.
+1. يسرّع المحرك كل ثانية كتلة هواء $\dot m = \rho A \left(v + \tfrac{\Delta v}{2}\right)$، أي الكثافة مضروبة في مساحة القرص وسرعة الهواء المتحرك عبره، بمقدار $\Delta v$.
2. يقول قانون نيوتن الثاني إن القوة اللازمة لتغيير هذا القدر من الزخم كل ثانية هي $T = \dot m\,\Delta v$. وبحسب القانون الثالث يدفع الهواء المحرك بالقوة نفسها إلى الأمام، وهذا رد الفعل هو الدفع.
3. تحريك كتلة هواء ضخمة بمقدار $\Delta v$ صغير يصنع الدفع نفسه الذي تصنعه كتلة صغيرة بمقدار $\Delta v$ ضخم، لكنه يهدر طاقة حركية أقل بكثير في العادم. لهذا بالضبط تنخفض كفاءة الدفع $\eta = \dfrac{2v}{2v+\Delta v}$ كلما كبرت $\Delta v$.
diff --git a/content/lessons/aerodynamics/propellers-and-jets/en.md b/content/lessons/aerodynamics/propellers-and-jets/en.md
index f46add51..c53bcf22 100644
--- a/content/lessons/aerodynamics/propellers-and-jets/en.md
+++ b/content/lessons/aerodynamics/propellers-and-jets/en.md
@@ -41,7 +41,7 @@ That trade matters because kinetic energy grows with speed squared, not speed. D
## Formal
-Thrust from momentum theory is $T = \dot m\, \Delta v$, where the mass flow rate through the propulsor's disc is $\dot m = \rho A v$ (density times disc area times the air's speed through it).
+Thrust from momentum theory is $T = \dot m\, \Delta v$, where the mass flow rate through the propulsor's disc is $\dot m = \rho A \left(v + \tfrac{\Delta v}{2}\right)$ (density times disc area times the air's speed through it, which is halfway between the incoming speed $v$ and the exhaust speed $v + \Delta v$).
The ideal propulsive efficiency — useful thrust power out, divided by total kinetic power put into the airflow — works out to $\eta = \dfrac{2v}{2v + \Delta v}$: it falls toward zero as $\Delta v$ grows relative to flight speed $v$, and rises toward 100% as $\Delta v \to 0$ (though thrust itself would then also fall toward zero, so real designs balance the two).
@@ -51,7 +51,7 @@ Real engines don't hit this ideal efficiency: extra losses come from the fan and
## Derivation
-1. Each second, the engine accelerates a mass of air $\dot m = \rho A v$ (density times disc area times the speed of air moving through it) up by $\Delta v$.
+1. Each second, the engine accelerates a mass of air $\dot m = \rho A \left(v + \tfrac{\Delta v}{2}\right)$ (density times disc area times the speed of air moving through it) up by $\Delta v$.
2. Newton's second law says the force needed to change that much momentum every second is $T = \dot m\,\Delta v$, and by the third law the air pushes back on the engine with the same force, forward: that reaction is thrust.
3. Moving a huge mass of air by a small $\Delta v$ makes the same thrust as moving a small mass by a huge $\Delta v$, but wastes far less kinetic energy in the exhaust — which is exactly why propulsive efficiency $\eta = \dfrac{2v}{2v+\Delta v}$ falls as $\Delta v$ grows.
diff --git a/content/lessons/aerodynamics/propellers-and-jets/lesson.yaml b/content/lessons/aerodynamics/propellers-and-jets/lesson.yaml
index df58b81f..8b8eb9f9 100644
--- a/content/lessons/aerodynamics/propellers-and-jets/lesson.yaml
+++ b/content/lessons/aerodynamics/propellers-and-jets/lesson.yaml
@@ -38,7 +38,7 @@ variables:
- \dot m
- \Delta v
derivation:
- - \dot m = \rho A v
+ - \dot m = \rho A \left(v + \tfrac{\Delta v}{2}\right)
- T = \dot m\, \Delta v
- \eta = \dfrac{2v}{2v + \Delta v}
charts: []
diff --git a/content/ui/ar/helicopters-and-rotors.yaml b/content/ui/ar/helicopters-and-rotors.yaml
index 62c29e02..47aec3ff 100644
--- a/content/ui/ar/helicopters-and-rotors.yaml
+++ b/content/ui/ar/helicopters-and-rotors.yaml
@@ -1,5 +1,6 @@
heli.hint: ▶ اسحب R والميل · تُميل الصفيحة المتأرجحة القرص كله، لا جسم الطائرة
heli.downwashLabel: تيار الهواء الهابط
heli.thrustLabel: الدفع (عمودي على القرص)
+heli.tilt: الميل
heli.dl: حمل القرص
heli.caption: منظر جانبي للتوضيح — ليس بمقياس رسم حقيقي.
diff --git a/content/ui/en/helicopters-and-rotors.yaml b/content/ui/en/helicopters-and-rotors.yaml
index 7f76eb38..1391ed92 100644
--- a/content/ui/en/helicopters-and-rotors.yaml
+++ b/content/ui/en/helicopters-and-rotors.yaml
@@ -1,5 +1,6 @@
heli.hint: ▶ drag R and tilt · the swashplate tilts the whole disc, not the fuselage
heli.downwashLabel: downwash
heli.thrustLabel: thrust (⟂ disc)
+heli.tilt: tilt
heli.dl: disc loading
heli.caption: Conceptual side view — not to scale.
diff --git a/src/viz/aerodynamics/HelicoptersAndRotors.vue b/src/viz/aerodynamics/HelicoptersAndRotors.vue
index 96792b1e..82d308e2 100644
--- a/src/viz/aerodynamics/HelicoptersAndRotors.vue
+++ b/src/viz/aerodynamics/HelicoptersAndRotors.vue
@@ -17,8 +17,8 @@ const CX = 420
const HUB_Y = 150
const RHO = 1.225
-const R = computed(() => Math.max(0.1, props.params.R ?? 3.84))
-const weight = computed(() => Math.max(1, props.params.W ?? 6076))
+const R = computed(() => Math.max(0.1, props.params.R ?? 3.8))
+const weight = computed(() => Math.max(1, props.params.W ?? 6075))
const tiltDeg = computed(() => props.params.tilt ?? 0)
const tiltRad = computed(() => (tiltDeg.value * Math.PI) / 180)
@@ -76,7 +76,7 @@ const downwash = computed(() => {
const readouts = computed(() => [
{ label: 'R', value: `${fmt(R.value, 2)} m` },
{ label: 'W', value: `${fmt(weight.value, 0)} N` },
- { label: 'tilt', value: `${fmt(tiltDeg.value, 1)}°` },
+ { label: t('heli.tilt'), value: `${fmt(tiltDeg.value, 1)}°` },
{ label: 'T', value: `${fmt(thrust.value, 0)} N`, color: 'var(--pos)' },
{ label: 'v_i', value: `${fmt(vi.value, 2)} m/s`, color: 'var(--accent)' },
{ label: 'P', value: `${fmt(power.value / 1000, 1)} kW` },
diff --git a/src/viz/aerodynamics/WingtipVorticesAndInducedDrag.vue b/src/viz/aerodynamics/WingtipVorticesAndInducedDrag.vue
index 045410a3..e0da5a5f 100644
--- a/src/viz/aerodynamics/WingtipVorticesAndInducedDrag.vue
+++ b/src/viz/aerodynamics/WingtipVorticesAndInducedDrag.vue
@@ -58,7 +58,8 @@ function spiral(ox: number, oy: number, size: number, spin: number, phase: numbe
return d
}
-const vortexSize = computed(() => Math.min(60, 12 + 34 * CL.value) * (winglets.value ? 0.7 : 1))
+// circulation at the tip goes like C_L x chord, and chord shrinks as 1/sqrt(AR) at fixed area
+const vortexSize = computed(() => Math.min(60, 12 + 34 * CL.value * Math.sqrt(9 / AR.value)) * (winglets.value ? 0.7 : 1))
const wing = computed(() => {
const hs = halfSpanPx.value
diff --git a/src/viz3d/aerodynamics/HelicoptersAndRotors3D.vue b/src/viz3d/aerodynamics/HelicoptersAndRotors3D.vue
index 63f3082a..0c2ff055 100644
--- a/src/viz3d/aerodynamics/HelicoptersAndRotors3D.vue
+++ b/src/viz3d/aerodynamics/HelicoptersAndRotors3D.vue
@@ -53,8 +53,8 @@ useThree(
let radiusScene = 1
return (dt, t0) => {
- const R = Math.max(0.1, props.params.R ?? 3.84)
- const weight = Math.max(1, props.params.W ?? 6076)
+ const R = Math.max(0.1, props.params.R ?? 3.8)
+ const weight = Math.max(1, props.params.W ?? 6075)
const tiltDeg = props.params.tilt ?? 0
const tiltRad = (tiltDeg * Math.PI) / 180
const A = Math.PI * R * R
From ecdbea56c7d2ba05752bb6473c66e56e74fa2a8a Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:22 +0300
Subject: [PATCH 08/10] fix: translate currency and unit labels in economics
visualizations
---
content/ui/ar/budgeting-and-saving.yaml | 2 ++
content/ui/ar/exchange-rates.yaml | 4 ++++
content/ui/ar/gdp-and-growth.yaml | 2 ++
content/ui/en/budgeting-and-saving.yaml | 2 ++
content/ui/en/exchange-rates.yaml | 4 ++++
content/ui/en/gdp-and-growth.yaml | 2 ++
src/viz/economics/BudgetingAndSaving.vue | 12 ++++++------
src/viz/economics/ExchangeRates.vue | 16 ++++++++--------
src/viz/economics/GdpAndGrowth.vue | 14 +++++++-------
9 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/content/ui/ar/budgeting-and-saving.yaml b/content/ui/ar/budgeting-and-saving.yaml
index 323c7eb5..4c8392c6 100644
--- a/content/ui/ar/budgeting-and-saving.yaml
+++ b/content/ui/ar/budgeting-and-saving.yaml
@@ -5,3 +5,5 @@ budget.savedLabel: مُدَّخر
budget.chartTitle: إجمالي المدخرات، شهرًا بعد شهر
budget.monthsUnit: شهر
budget.caption: خط مستقيم؛ نفس الادخار يُجمع شهرًا بعد شهر
+budget.money: '{n} ريال'
+budget.perMonth: '{n} ريال/شهر'
diff --git a/content/ui/ar/exchange-rates.yaml b/content/ui/ar/exchange-rates.yaml
index f9199f89..ebd2d38f 100644
--- a/content/ui/ar/exchange-rates.yaml
+++ b/content/ui/ar/exchange-rates.yaml
@@ -7,3 +7,7 @@ fx.costCaption: سعر المستورد × سعر الصرف
fx.fxTitle: جنيهاتك، محوَّلة
fx.fxCaption: الجنيهات ÷ سعر الصرف
fx.caption: نفس السعر يحرّك اللوحتين معًا؛ جنيه أضعف يرفع الشريط الأيسر ويخفض الأيمن
+fx.usd: '{n} دولار'
+fx.egp: '{n} جنيه'
+fx.rate: '{n} جنيه/دولار'
+fx.rateLong: '{n} جنيه لكل دولار'
diff --git a/content/ui/ar/gdp-and-growth.yaml b/content/ui/ar/gdp-and-growth.yaml
index 955d7a80..a90b569c 100644
--- a/content/ui/ar/gdp-and-growth.yaml
+++ b/content/ui/ar/gdp-and-growth.yaml
@@ -3,3 +3,5 @@ gdp.years: سنة
gdp.exactLabel: التضاعف الحقيقي عند
gdp.ruleLabel: قاعدة السبعين تقول
gdp.caption: علامتا تضاعف متقاربتان جدًا؛ الاختصار يتابع المنحنى الحقيقي عن قرب
+gdp.bn: '{n} مليار دولار'
+gdp.perYear: '{n}% سنويًا'
diff --git a/content/ui/en/budgeting-and-saving.yaml b/content/ui/en/budgeting-and-saving.yaml
index 4870a39c..5a0d316c 100644
--- a/content/ui/en/budgeting-and-saving.yaml
+++ b/content/ui/en/budgeting-and-saving.yaml
@@ -5,3 +5,5 @@ budget.savedLabel: saved
budget.chartTitle: total saved, month by month
budget.monthsUnit: mo
budget.caption: a straight line — the same saving added up, month after month
+budget.money: '${n}'
+budget.perMonth: '${n}/mo'
diff --git a/content/ui/en/exchange-rates.yaml b/content/ui/en/exchange-rates.yaml
index 3d5e3152..2f09eb07 100644
--- a/content/ui/en/exchange-rates.yaml
+++ b/content/ui/en/exchange-rates.yaml
@@ -7,3 +7,7 @@ fx.costCaption: import price × exchange rate
fx.fxTitle: your pounds, converted
fx.fxCaption: pounds ÷ exchange rate
fx.caption: the same rate drives both panels — a weaker pound raises the left bar and lowers the right one
+fx.usd: '${n}'
+fx.egp: '{n} EGP'
+fx.rate: '{n} EGP/$'
+fx.rateLong: '{n} EGP / $1'
diff --git a/content/ui/en/gdp-and-growth.yaml b/content/ui/en/gdp-and-growth.yaml
index 54af0a43..6467294f 100644
--- a/content/ui/en/gdp-and-growth.yaml
+++ b/content/ui/en/gdp-and-growth.yaml
@@ -3,3 +3,5 @@ gdp.years: yr
gdp.exactLabel: exact double at
gdp.ruleLabel: rule of 70 says
gdp.caption: two doubling markers, barely apart — the shortcut tracks the real curve closely
+gdp.bn: '${n}bn'
+gdp.perYear: '{n}%/yr'
diff --git a/src/viz/economics/BudgetingAndSaving.vue b/src/viz/economics/BudgetingAndSaving.vue
index ff1af5c6..eb399e1f 100644
--- a/src/viz/economics/BudgetingAndSaving.vue
+++ b/src/viz/economics/BudgetingAndSaving.vue
@@ -43,11 +43,11 @@ const areaPoints = computed(() => `${PLOT.x},${yScale.value(0)} ${linePoints.val
const zeroY = computed(() => yScale.value(0))
const readouts = computed(() => [
- { label: 'I', value: `$${fmt(income.value, 0)}/mo` },
- { label: 'X', value: `$${fmt(spending.value, 0)}/mo` },
- { label: 'S', value: `$${fmt(saving.value, 0)}/mo`, color: saving.value >= 0 ? 'var(--accent-2)' : 'var(--danger, #d33)' },
- { label: 'm', value: `${months.value} mo` },
- { label: 'T', value: `$${fmt(total.value, 0)}`, color: 'var(--accent)' },
+ { label: 'I', value: t('budget.perMonth', { n: fmt(income.value, 0) }) },
+ { label: 'X', value: t('budget.perMonth', { n: fmt(spending.value, 0) }) },
+ { label: 'S', value: t('budget.perMonth', { n: fmt(saving.value, 0) }), color: saving.value >= 0 ? 'var(--accent-2)' : 'var(--danger, #d33)' },
+ { label: 'm', value: `${months.value} ${t('budget.monthsUnit')}` },
+ { label: 'T', value: t('budget.money', { n: fmt(total.value, 0) }), color: 'var(--accent)' },
])
@@ -71,7 +71,7 @@ const readouts = computed(() => [
- ${{ fmt(total, 0) }}
+ {{ t('budget.money', { n: fmt(total, 0) }) }}
0 {{ t('budget.monthsUnit') }}
{{ months }} {{ t('budget.monthsUnit') }}
diff --git a/src/viz/economics/ExchangeRates.vue b/src/viz/economics/ExchangeRates.vue
index 61d53ff7..0d5f773e 100644
--- a/src/viz/economics/ExchangeRates.vue
+++ b/src/viz/economics/ExchangeRates.vue
@@ -35,11 +35,11 @@ const FX = { x: 580, y: 150, w: 160, h: 220, max: 300 }
const fxFill = computed(() => Math.min(1, foreign.value / FX.max) * FX.h)
const readouts = computed(() => [
- { label: 'p', value: `$${fmt(price.value, 0)}` },
- { label: 'e', value: `${fmt(rate.value, 1)} EGP/$` },
- { label: 'm', value: `${fmt(pounds.value, 0)} EGP` },
- { label: 'c', value: `${fmt(cost.value, 0)} EGP`, color: 'var(--accent-2)' },
- { label: 'f', value: `$${fmt(foreign.value, 1)}`, color: 'var(--accent)' },
+ { label: 'p', value: t('fx.usd', { n: fmt(price.value, 0) }) },
+ { label: 'e', value: t('fx.rate', { n: fmt(rate.value, 1) }) },
+ { label: 'm', value: t('fx.egp', { n: fmt(pounds.value, 0) }) },
+ { label: 'c', value: t('fx.egp', { n: fmt(cost.value, 0) }), color: 'var(--accent-2)' },
+ { label: 'f', value: t('fx.usd', { n: fmt(foreign.value, 1) }), color: 'var(--accent)' },
])
@@ -55,20 +55,20 @@ const readouts = computed(() => [
{{ t('fx.strong') }}
{{ t('fx.weak') }}
- {{ fmt(rate, 1) }} EGP / $1
+ {{ t('fx.rateLong', { n: fmt(rate, 1) }) }}
{{ t('fx.costTitle') }}
- {{ fmt(cost, 0) }} EGP
+ {{ t('fx.egp', { n: fmt(cost, 0) }) }}
{{ t('fx.costCaption') }}
{{ t('fx.fxTitle') }}
- ${{ fmt(foreign, 1) }}
+ {{ t('fx.usd', { n: fmt(foreign, 1) }) }}
{{ t('fx.fxCaption') }}
{{ t('fx.caption') }}
diff --git a/src/viz/economics/GdpAndGrowth.vue b/src/viz/economics/GdpAndGrowth.vue
index e3d1eac0..be4d334e 100644
--- a/src/viz/economics/GdpAndGrowth.vue
+++ b/src/viz/economics/GdpAndGrowth.vue
@@ -41,11 +41,11 @@ const nowX = computed(() => px(tNow.value))
const nowY = computed(() => py(output.value))
const readouts = computed(() => [
- { label: 'p', value: `$${fmt(p0.value, 0)}bn` },
- { label: 'g', value: `${fmt(g.value, 2)}%/yr` },
- { label: 't', value: `${fmt(tNow.value, 0)} yr` },
- { label: 'Y', value: `$${fmt(output.value, 0)}bn`, color: 'var(--accent)' },
- { label: 'd (70/g)', value: `${fmt(ruleDouble.value, 1)} yr`, color: 'var(--accent-2)' },
+ { label: 'p', value: t('gdp.bn', { n: fmt(p0.value, 0) }) },
+ { label: 'g', value: t('gdp.perYear', { n: fmt(g.value, 2) }) },
+ { label: 't', value: `${fmt(tNow.value, 0)} ${t('gdp.years')}` },
+ { label: 'Y', value: t('gdp.bn', { n: fmt(output.value, 0) }), color: 'var(--accent)' },
+ { label: 'd (70/g)', value: `${fmt(ruleDouble.value, 1)} ${t('gdp.years')}`, color: 'var(--accent-2)' },
])
@@ -62,7 +62,7 @@ const readouts = computed(() => [
- 2p = ${{ fmt(2 * p0, 0) }}bn
+ 2p = {{ t('gdp.bn', { n: fmt(2 * p0, 0) }) }}
@@ -78,7 +78,7 @@ const readouts = computed(() => [
- ${{ fmt(output, 0) }}bn
+ {{ t('gdp.bn', { n: fmt(output, 0) }) }}
{{ t('gdp.caption') }}
From d02eb316434a64fc7c26f95ad6e04ed6fdaa70e5 Mon Sep 17 00:00:00 2001
From: ru44 <18311071+ru44@users.noreply.github.com>
Date: Wed, 25 Nov 2026 08:40:40 +0300
Subject: [PATCH 09/10] fix: computing, data and networking visualizations
count and label correctly
---
content/lessons/ai/attention/ar.md | 2 +-
content/lessons/ai/attention/en.md | 2 +-
content/lessons/ai/neural-network/lesson.yaml | 4 ++--
content/lessons/ai/tokenization/ar.md | 12 ++++++------
content/lessons/ai/tokenization/en.md | 12 ++++++------
content/lessons/ai/tokenization/lesson.yaml | 10 +++++-----
.../computer-science/breadth-first-search/ar.md | 2 +-
.../computer-science/breadth-first-search/en.md | 2 +-
.../computer-science/depth-first-search/ar.md | 8 ++++----
.../computer-science/depth-first-search/en.md | 8 ++++----
.../cryptography/rsa-encryption/lesson.yaml | 2 +-
.../data/bits-bytes-and-data-sizes/ar.md | 2 +-
.../data/bits-bytes-and-data-sizes/en.md | 2 +-
.../data/bits-bytes-and-data-sizes/lesson.yaml | 4 ++--
.../discrete/graphs-and-euler-paths/ar.md | 2 +-
.../discrete/graphs-and-euler-paths/en.md | 2 +-
content/lessons/networking/nas-and-raid/ar.md | 2 +-
content/lessons/networking/nas-and-raid/en.md | 2 +-
content/ui/ar.yaml | 1 +
content/ui/ar/compression-entropy.yaml | 1 +
content/ui/ar/join-tables.yaml | 2 ++
content/ui/en.yaml | 1 +
content/ui/en/compression-entropy.yaml | 1 +
content/ui/en/join-tables.yaml | 2 ++
src/viz/ai/NeuralNet.vue | 4 ++--
src/viz/ai/PolyFit.vue | 6 ++++--
src/viz/ai/Tokenizer.vue | 2 +-
src/viz/computer-science/SortSteps.vue | 2 +-
src/viz/cryptography/LatticeCrypto.vue | 17 +++++++++++++++--
src/viz/data/CompressionEntropy.vue | 2 +-
src/viz/data/JoinTables.vue | 4 ++--
src/viz/networking/NasRaid.vue | 4 ++--
src/viz/shared/GraphSearch.vue | 16 ++++++++++++++--
src/viz/shared/PowersOfTen.vue | 4 ++--
34 files changed, 92 insertions(+), 57 deletions(-)
diff --git a/content/lessons/ai/attention/ar.md b/content/lessons/ai/attention/ar.md
index 70331248..a7aa82b4 100644
--- a/content/lessons/ai/attention/ar.md
+++ b/content/lessons/ai/attention/ar.md
@@ -40,7 +40,7 @@ variables:
## Formal
-تُقاس الصلة بين الاستعلام $q$ ومفتاح كل كلمة $k_i$ بجداء نقطي، ثم تتحوّل إلى أوزان مجموعها واحد عبر Softmax: $a_i = \frac{\exp\!\big((q\cdot k_i)/T\big)}{\sum_j \exp\!\big((q\cdot k_j)/T\big)}$. المخرج يمزج قيمة كل كلمة $v_i$ بوزنها $a_i$.
+تُقاس الصلة بين الاستعلام $q$ ومفتاح كل كلمة $k_i$ بجداء نقطي، ثم تتحوّل إلى أوزان مجموعها واحد عبر Softmax: $a_i = \frac{\exp\!\big((q\cdot k_i)/T\big)}{\sum_j \exp\!\big((q\cdot k_j)/T\big)}$. المخرج يمزج قيمة كل كلمة $v_i$ بوزنها $a_i$. في هذه الصورة يُقصَّر سهم كل كلمة أولًا إلى الطول 1، فيقيس الجداء النقطي فقط مدى اتفاق السهمين في الاتجاه (تشابه جيب التمام).
الحرارة $T$ تتحكّم في مدى حدّة تلك الأوزان. $T$ منخفضة تضع معظم الوزن على الكلمة الأعلى درجة وحدها، و$T$ مرتفعة توزّع الوزن بالتساوي تقريبًا على كل الكلمات مهما كانت درجتها، تمامًا كمنزلق الحرارة في التنبّؤ بالكلمة التالية.
diff --git a/content/lessons/ai/attention/en.md b/content/lessons/ai/attention/en.md
index f2fc06a1..562f8318 100644
--- a/content/lessons/ai/attention/en.md
+++ b/content/lessons/ai/attention/en.md
@@ -40,7 +40,7 @@ That blend is what attention computes. The current word asks a question (its que
## Formal
-Relevance between the query $q$ and each word's key $k_i$ is scored by a dot product, then turned into weights that sum to one with a softmax: $a_i = \frac{\exp\!\big((q\cdot k_i)/T\big)}{\sum_j \exp\!\big((q\cdot k_j)/T\big)}$. The output blends every word's value $v_i$ by its weight $a_i$.
+Relevance between the query $q$ and each word's key $k_i$ is scored by a dot product, then turned into weights that sum to one with a softmax: $a_i = \frac{\exp\!\big((q\cdot k_i)/T\big)}{\sum_j \exp\!\big((q\cdot k_j)/T\big)}$. The output blends every word's value $v_i$ by its weight $a_i$. In this picture every word arrow is first shrunk to length 1, so the dot product only measures how closely two arrows point the same way (cosine similarity).
The temperature $T$ controls how peaked those weights are: a low $T$ pushes almost all the weight onto the single highest-scoring word, a high $T$ spreads weight nearly evenly across every word regardless of score, exactly like the temperature slider in next-token prediction.
diff --git a/content/lessons/ai/neural-network/lesson.yaml b/content/lessons/ai/neural-network/lesson.yaml
index ee429af9..03eb952e 100644
--- a/content/lessons/ai/neural-network/lesson.yaml
+++ b/content/lessons/ai/neural-network/lesson.yaml
@@ -36,7 +36,7 @@ parameters:
min: -3
max: 3
step: 0.1
- value: 1
+ value: -1
w31:
min: -3
max: 3
@@ -92,7 +92,7 @@ presets:
- w11: 1
w12: 1
w21: 1
- w22: 1
+ w22: -1
w31: -1
w32: 1
v1: 1
diff --git a/content/lessons/ai/tokenization/ar.md b/content/lessons/ai/tokenization/ar.md
index d2241bbe..db85b8e4 100644
--- a/content/lessons/ai/tokenization/ar.md
+++ b/content/lessons/ai/tokenization/ar.md
@@ -15,20 +15,20 @@ variables:
## Try it
1. اضبط merges على 0 واقرأ الرقاقات: كل حرف رمز وحده، وعلامة ▁ تعني بداية كلمة، والعدّاد يُظهر 49 رمزًا. هكذا يقرأ نموذج لا معجم عنده: زحفًا، حرفًا حرفًا.
-2. ارفع merges من 0 إلى 6 خطوة خطوة وشاهد القاعدة تعمل: تلتصق «▁th»، ثم «▁the»، ثم «▁cat» فتصير كل منها رقاقة واحدة، وتبقى الكلمات النادرة قطعًا. ينزل العدد من 49 إلى 31. وبعد 6 لا يتغيّر شيء، لأنه لم يبقَ زوج يتكرر مرتين.
-3. أبقِ merges عند 10 واضبط text على 1 (الشيفرة) ثم 2 (العربية). الشيفرة تنزل من 38 رمزًا إلى 34 فقط لأنه لا يكاد يتكرر فيها شيء، والعربية تنزل من 44 إلى 32 حين تصير «▁القطة» رقاقة واحدة. الرقاقات تأتي من التكرار، ولهذا لا ينفع معجم نما على نوع من النصوص نوعًا آخر كما ينبغي.
+2. ارفع merges من 0 إلى 6 خطوة خطوة وشاهد القاعدة تعمل: تلتصق «▁th»، ثم «▁the»، ثم «▁cat» فتصير كل منها رقاقة واحدة، وتبقى الكلمات النادرة قطعًا. ينزل العدد من 49 إلى 31. ويقف المنزلق عند 6، لأنه لم يبقَ بعدها زوج يتكرر مرتين.
+3. أبقِ merges عند 6 واضبط text على 1 (الشيفرة) ثم 2 (العربية). الشيفرة تنزل من 38 رمزًا إلى 34 فقط لأنه لا يكاد يتكرر فيها شيء، والعربية تنزل من 44 إلى 32 حين تصير «▁القطة» رقاقة واحدة. الرقاقات تأتي من التكرار، ولهذا لا ينفع معجم نما على نوع من النصوص نوعًا آخر كما ينبغي.
## Real-life examples
- **جملة إنجليزية بلا معجم.** جملة القط تكلف 49 رمزًا، رمزًا لكل حرف. بهذا المعدل تغرق صفحة واحدة النموذج قبل أن يقول شيئًا.
-- **الجملة نفسها بعد 25 دمجة.** الكلمتان المتكررتان «the» و«cat» صارتا رقاقتين مفردتين ونزل العدد من 49 إلى 31. ضغطٌ سببه التكرار وحده. والدمجات الست الأولى فقط هي التي عملت، فبعدها لم يبقَ في هذه الجملة القصيرة زوج يتكرر.
-- **العربية عند 12 دمجة.** القاعدة تعمل على أي لغة، فتنزل هذه الجملة من 44 رمزًا إلى 32. لكن معجمًا تدرب على الإنجليزية أنفق رقاقاته هناك. لهذا تكلف الجملة نفسها رموزًا أكثر بلغات أخرى.
+- **الجملة نفسها بعد 6 دمجات.** الكلمتان المتكررتان «the» و«cat» صارتا رقاقتين مفردتين ونزل العدد من 49 إلى 31. ضغطٌ سببه التكرار وحده. وبعد 6 دمجات لم يبقَ في هذه الجملة القصيرة زوج يتكرر، ولهذا يقف المنزلق هناك.
+- **العربية عند 5 دمجات.** القاعدة تعمل على أي لغة، فتنزل هذه الجملة من 44 رمزًا إلى 32. لكن معجمًا تدرب على الإنجليزية أنفق رقاقاته هناك. لهذا تكلف الجملة نفسها رموزًا أكثر بلغات أخرى.
## Test yourself
1. اضبط الدمجات على صفر واقرأ جملة كما يقرؤها نموذج بلا معجم.
-2. أعطِ الجملة الإنجليزية 25 دمجة على الأقل وشاهد كلمات كاملة تصير رقاقة واحدة.
-3. خذ العينة العربية إلى 10 دمجات أو أكثر وقارن رقاقاتها برقاقات الإنجليزية.
+2. أعطِ الجملة الإنجليزية الدمجات الست كلها وشاهد كلمات كاملة تصير رقاقة واحدة.
+3. خذ العينة العربية إلى 5 دمجات أو أكثر وقارن رقاقاتها برقاقات الإنجليزية.
## Intuition
diff --git a/content/lessons/ai/tokenization/en.md b/content/lessons/ai/tokenization/en.md
index 777e001f..b2b65471 100644
--- a/content/lessons/ai/tokenization/en.md
+++ b/content/lessons/ai/tokenization/en.md
@@ -16,20 +16,20 @@ variables:
## Try it
1. Set merges to 0 and read the chips: every character is its own token, word starts marked with ▁, and the readout counts 49 tokens — this is the crawl a model would face with no vocabulary at all.
-2. Drag merges from 0 to 6 one step at a time and watch the greedy rule work: «▁th», then «▁the», then «▁cat» fuse into single chips while rare words stay in pieces. The count falls from 49 to 31; past 6 nothing changes, because no pair is left that appears twice.
-3. Keep merges at 10 and set text to 1 (code), then 2 (Arabic). The code only shrinks from 38 tokens to 34 because almost nothing in it repeats; the Arabic shrinks from 44 to 32 once «▁القطة» becomes one chip. Chips are earned by repetition — which is why a vocabulary grown on one kind of text serves another kind badly.
+2. Drag merges from 0 to 6 one step at a time and watch the greedy rule work: «▁th», then «▁the», then «▁cat» fuse into single chips while rare words stay in pieces. The count falls from 49 to 31; the slider stops at 6, because by then no pair is left that appears twice.
+3. Keep merges at 6 and set text to 1 (code), then 2 (Arabic). The code only shrinks from 38 tokens to 34 because almost nothing in it repeats; the Arabic shrinks from 44 to 32 once «▁القطة» becomes one chip. Chips are earned by repetition — which is why a vocabulary grown on one kind of text serves another kind badly.
## Real-life examples
- **Plain English, no vocabulary.** The cat sentence costs 49 character-tokens — at this rate a page of text would swamp the model before it said anything.
-- **The same sentence, 25 merges later.** The repeated words «the» and «cat» have fused into single chips and the count drops from 49 to 31 — compression earned purely by repetition. Only the first 6 merges did any work; after that this short sentence has no repeated pair left.
-- **Arabic at 12 merges.** The greedy rule works on any script, taking this sentence from 44 tokens to 32 — but a vocabulary trained mostly on English spends its chips there, which is why the same sentence often costs more tokens in other languages.
+- **The same sentence, 6 merges later.** The repeated words «the» and «cat» have fused into single chips and the count drops from 49 to 31 — compression earned purely by repetition. After 6 merges this short sentence has no repeated pair left, so the slider stops there.
+- **Arabic at 5 merges.** The greedy rule works on any script, taking this sentence from 44 tokens to 32 — but a vocabulary trained mostly on English spends its chips there, which is why the same sentence often costs more tokens in other languages.
## Test yourself
1. Set merges to zero and read a sentence the way a vocabulary-less model would.
-2. Give English at least 25 merges and watch whole words become single chips.
-3. Take the Arabic sample to 10 merges or more and compare its chips to the English ones.
+2. Give English all 6 merges and watch whole words become single chips.
+3. Take the Arabic sample to 5 merges or more and compare its chips to the English ones.
## Intuition
diff --git a/content/lessons/ai/tokenization/lesson.yaml b/content/lessons/ai/tokenization/lesson.yaml
index 5aabf37b..a5c5328b 100644
--- a/content/lessons/ai/tokenization/lesson.yaml
+++ b/content/lessons/ai/tokenization/lesson.yaml
@@ -17,7 +17,7 @@ visualization:
parameters:
merges:
min: 0
- max: 30
+ max: 6
step: 1
value: 3
text:
@@ -38,11 +38,11 @@ primary: merges
presets:
- merges: 0
text: 0
- - merges: 25
+ - merges: 6
text: 0
- - merges: 12
+ - merges: 5
text: 2
challenges:
- check: merges == 0
- - check: text == 0 and merges >= 25
- - check: text == 2 and merges >= 10
+ - check: text == 0 and merges >= 6
+ - check: text == 2 and merges >= 5
diff --git a/content/lessons/computer-science/breadth-first-search/ar.md b/content/lessons/computer-science/breadth-first-search/ar.md
index 3ab4beb0..0df5d734 100644
--- a/content/lessons/computer-science/breadth-first-search/ar.md
+++ b/content/lessons/computer-science/breadth-first-search/ar.md
@@ -14,7 +14,7 @@ variables:
## Try it
-1. اترك «البداية» عند 0 (الدائرة A) وحرّك «الخطوة» ببطء من 0 إلى 1. تضيء الدائرة A أولًا، ثم جارتاها المباشرتان B وF طبقةً واحدة، ثم جارتاهما C وG طبقةً تالية. تنتهي قراءة ترتيب الزيارة هكذا: A B F C G D H E I J. وقراءة طول المسار، 22، هي مجموع الأرقام على الخطوط الخمسة في المسار إلى J.
+1. اترك «البداية» عند 0 (الدائرة A) وحرّك «الخطوة» ببطء من 0 إلى 1. تضيء الدائرة A أولًا، ثم جارتاها المباشرتان B وF طبقةً واحدة، ثم جارتاهما C وG طبقةً تالية. تنتهي قراءة ترتيب الزيارة هكذا: A B F C G D H E I J. وقراءة طول المسار، 5، هي عدد الخطوط في المسار إلى J، ولا دخل للأرقام المكتوبة على الخطوط.
2. حرّك «الخطوة» إلى 0 ثم إلى الأمام من جديد لإعادة تشغيل الطبقات واحدة تلو الأخرى، ولاحظ أن الهدف، الدائرة J، يضيء فقط بعد استكشاف كل طبقة أقرب منها.
3. اضبط «البداية» على 5 (الدائرة F) وحرّك «الخطوة» إلى النهاية مرة أخرى. تُرسم الطبقات من نقطة البداية الجديدة، ويُكتشف الهدف بعد 4 قفزات (F ثم G ثم H ثم I ثم J) بدل 5، وهذا دائمًا أقل عدد ممكن.
diff --git a/content/lessons/computer-science/breadth-first-search/en.md b/content/lessons/computer-science/breadth-first-search/en.md
index 74bf8892..bec6efcd 100644
--- a/content/lessons/computer-science/breadth-first-search/en.md
+++ b/content/lessons/computer-science/breadth-first-search/en.md
@@ -14,7 +14,7 @@ variables:
## Try it
-1. Leave «start» at 0 (circle A) and drag «step» slowly from 0 to 1 — circle A lights up first, then its direct neighbours B and F as one layer, then their neighbours C and G as the next layer. The visit order readout ends as A B F C G D H E I J, and the path length readout, 22, adds up the numbers on the 5 edges of the path to J.
+1. Leave «start» at 0 (circle A) and drag «step» slowly from 0 to 1 — circle A lights up first, then its direct neighbours B and F as one layer, then their neighbours C and G as the next layer. The visit order readout ends as A B F C G D H E I J, and the path length readout, 5, counts the edges on the path to J; the numbers printed on the edges play no part.
2. Drag «step» back to 0 and forward again to replay the layers one at a time, and notice the goal, circle J, only lights up once every closer layer has already been explored.
3. Set «start» to 5 (circle F) and drag «step» to the end again — the layers redraw from the new starting point, and the goal is found in 4 hops (F, G, H, I, J) instead of 5, still the fewest possible.
diff --git a/content/lessons/computer-science/depth-first-search/ar.md b/content/lessons/computer-science/depth-first-search/ar.md
index f3fe4c34..a8ae9018 100644
--- a/content/lessons/computer-science/depth-first-search/ar.md
+++ b/content/lessons/computer-science/depth-first-search/ar.md
@@ -16,25 +16,25 @@ variables:
1. اضبط منزلق «البداية» على 0 (الدائرة A)، ثم حرّك «الخطوة» ببطء من 0 نحو 1. راقب مسارًا واحدًا يتلوّى من A نحو الهدف، الدائرة J، جارًا واحدًا في كل مرة: A ثم F ثم G ثم H ثم I ثم J.
2. أعد «الخطوة» إلى 0، ثم اضبط «البداية» على 9 (الدائرة J). يبدأ المسار عند الهدف نفسه، فتكون J أول دائرة يزورها البحث.
-3. اضبط «البداية» على 3 (الدائرة D) وحرّك «الخطوة» بعد منتصف الشريط. يمضي المسار D ثم I ثم J، ولا يجد عند J جارًا جديدًا، فيتراجع: يرجع إلى الجار الآخر للدائرة I، وهو H.
+3. اضبط «البداية» على 3 (الدائرة D) وحرّك «الخطوة» بعد منتصف الشريط. يمضي المسار D ثم I ثم J ثم E، ولا يجد عند E جارًا جديدًا، فيتراجع: يرجع إلى الجار الآخر للدائرة I، وهو H.
## Real-life examples
- **استكشاف متاهة من بوابتها.** ابدأ من 0 (الغرفة A)، وهي البوابة، وحرّك «الخطوة» حتى النهاية (1). يظهر المسار الوحيد الذي يلتزم به DFS، وهو A F G H I J، ويصل إلى المخرج دون أن يصادف طريقًا مسدودًا.
- **أنت عند المخرج أصلًا.** ابدأ من 9 (الغرفة J)، وهي نفسها الهدف، وأبقِ «الخطوة» عند البداية (0). ينتهي البحث فورًا، لأنك تقف عند المخرج أصلًا.
-- **البدء من منتصف المتاهة.** ابدأ من 3 (الغرفة D) وحرّك «الخطوة» حتى النهاية (1). يصل المسار إلى J بعد حركتين، ثم يرجع إلى H ليكمل استكشاف بقية الغرف.
+- **البدء من منتصف المتاهة.** ابدأ من 3 (الغرفة D) وحرّك «الخطوة» حتى النهاية (1). يصل المسار إلى J بعد حركتين، ويتقدّم إلى E، ثم يرجع إلى H ليكمل استكشاف بقية الغرف.
## Test yourself
1. ابدأ البحث من 0 (الدائرة A) وحرّك موضع التشغيل حتى نهايته.
2. انقل عقدة البداية إلى 9 (الدائرة J)، فوق الهدف مباشرة، فيجد البحث الهدف فورًا.
-3. ابدأ البحث من 3 (الدائرة D) وحرّك موضع التشغيل بعد المنتصف. التقط لحظة تراجع المسار من J إلى H.
+3. ابدأ البحث من 3 (الدائرة D) وحرّك موضع التشغيل بعد المنتصف. التقط لحظة تراجع المسار من E إلى H.
## Intuition
تخيل متاهة فيها 10 غرف أسماؤها من A إلى J، ولها مخرج واحد في الغرفة J. اضبط منزلق «البداية» على 0 (الغرفة A) وحرّك «الخطوة» ببطء نحو اليمين. يخرج مسار واحد من الغرفة A، يلتزم بباب واحد في كل مرة ويغوص بأقصى ما تسمح به المتاهة، بدل الانتشار إلى كل الغرف القريبة دفعة واحدة. فقط حين لا يبقى للغرفة الحالية باب غير مستكشَف، يرجع المسار، أي يتراجع، إلى أقرب غرفة لا يزال فيها باب لم يُجرَّب.
-هذا التراجع هو بالضبط ما تفعله حين ترجع على خطواتك في متاهة حقيقية بعد أن تصل إلى طريق مسدود، فأنت لا تبدأ من جديد بل ترجع إلى آخر مفترق فيه باب لم تجرّبه. حرّك «البداية» إلى 3 (الغرفة D) بدل 0، وراقب المسار يصل إلى الغرفة J، وهي الهدف، ثم يرجع إلى H لأن J ليس فيها باب لم يُجرَّب. يحتفظ DFS بأول مسار يجده، وغالبًا ما يكون أطول من أقصر طريق للخروج: من الغرفة E (البداية = 4) يمشي مباشرة إلى J فتُظهر قراءة طول المسار 6، مع أن المرور عبر I مجموعه 5 فقط.
+هذا التراجع هو بالضبط ما تفعله حين ترجع على خطواتك في متاهة حقيقية بعد أن تصل إلى طريق مسدود، فأنت لا تبدأ من جديد بل ترجع إلى آخر مفترق فيه باب لم تجرّبه. حرّك «البداية» إلى 3 (الغرفة D) بدل 0، وراقب المسار يصل إلى الغرفة J، وهي الهدف، ويتقدّم إلى E، ثم يرجع إلى H لأن E ليس فيها باب لم يُجرَّب. يحتفظ DFS بأول مسار يجده ولا ينظر أبدًا إلى الأرقام المكتوبة على الطرق: من الغرفة E (البداية = 4) يمشي مباشرة إلى J فتُظهر قراءة طول المسار خطوة واحدة (1)، مع أن ذلك الطريق يكلّف 6 والمرور عبر I مجموعه 5 فقط.
## Formal
diff --git a/content/lessons/computer-science/depth-first-search/en.md b/content/lessons/computer-science/depth-first-search/en.md
index e0511931..e5dd51ce 100644
--- a/content/lessons/computer-science/depth-first-search/en.md
+++ b/content/lessons/computer-science/depth-first-search/en.md
@@ -19,25 +19,25 @@ variables:
1. Set the slider "start" to 0 (circle A) and drag "step" slowly from 0 toward 1 — watch a single path snake from A toward the goal, circle J, one neighbour at a time: A, F, G, H, I, J.
2. Drag "step" back to 0, then set "start" to 9 (circle J) — the path begins right on the goal, so J is the very first circle visited.
-3. Set "start" to 3 (circle D) and slide "step" past the halfway point — the path goes D, I, J, finds no new neighbour at J, and backtracks: it jumps back to I's other neighbour, H.
+3. Set "start" to 3 (circle D) and slide "step" past the halfway point — the path goes D, I, J, E, finds no new neighbour at E, and backtracks: it jumps back to I's other neighbour, H.
## Real-life examples
- **Exploring a corn maze from the gate.** Starting at 0 (room A), the entrance, with the play position run to the end (step = 1) shows the one path DFS commits to, A F G H I J, reaching the exit without a single dead end on the way.
- **Already standing at the exit.** Starting at 9 (room J), the same room as the goal, with the play position paused at the very beginning (step = 0) shows the search finishing instantly, because there is nowhere left to go.
-- **Starting from the middle of the maze.** Starting at 3 (room D) and running the play position all the way to the end (step = 1) shows the path reach J after two moves, then double back to H to finish exploring the other rooms.
+- **Starting from the middle of the maze.** Starting at 3 (room D) and running the play position all the way to the end (step = 1) shows the path reach J after two moves, step on to E, then double back to H to finish exploring the other rooms.
## Test yourself
1. Start the search at 0 (circle A) and drag the play position all the way to the end.
2. Move the starting node to 9 (circle J), right on top of the goal itself — the search that finds it instantly.
-3. Start the search at 3 (circle D) and push the play position past halfway — catch the path backtracking from J to H.
+3. Start the search at 3 (circle D) and push the play position past halfway — catch the path backtracking from E to H.
## Intuition
Picture a corn maze with 10 rooms lettered A to J, and a single exit at room J. Set the slider "start" to 0 (room A) and slide "step" slowly to the right: a single path snakes out from room A, committing to one doorway at a time and diving as deep as the maze allows, instead of spreading out to every nearby room at once. Only when the current room has no unexplored doorway left does the path step back — backtrack — to the most recent room that still has one.
-That backing-up behaviour is exactly what happens when you retrace your steps in a real maze after hitting a dead end: you don't start over, you just return to the last junction with an unused turn. Move "start" to 3 (room D) instead of 0 and watch the path reach room J, the goal, and then double back to H because J has no unexplored doorway. DFS keeps whichever path it finds first, which is often longer than the shortest way out: from room E (start = 4) it walks straight to J and the path length readout shows 6, although going through I would add up to only 5.
+That backing-up behaviour is exactly what happens when you retrace your steps in a real maze after hitting a dead end: you don't start over, you just return to the last junction with an unused turn. Move "start" to 3 (room D) instead of 0 and watch the path reach room J, the goal, step on to E, and then double back to H because E has no unexplored doorway. DFS keeps whichever path it finds first and never looks at the numbers on the roads: from room E (start = 4) it walks straight to J and the path length readout shows 1 step, although that road costs 6 and going through I would add up to only 5.
## Formal
diff --git a/content/lessons/cryptography/rsa-encryption/lesson.yaml b/content/lessons/cryptography/rsa-encryption/lesson.yaml
index 4c72b811..7f2bcf84 100644
--- a/content/lessons/cryptography/rsa-encryption/lesson.yaml
+++ b/content/lessons/cryptography/rsa-encryption/lesson.yaml
@@ -52,5 +52,5 @@ presets:
m: 2
challenges:
- check: abs(p-5)<0.5 and abs(q-11)<0.5 and abs(m-7)<0.5
- - check: abs(p-q)<0.5
+ - check: 'abs(p-q)<0.5 or (abs(p-3.5)<1 and abs(q-3.5)<1) or (abs(p-5.5)<1 and abs(q-5.5)<1) or (abs(p-8)<1.5 and abs(q-8)<1.5) or (abs(p-11)<1.5 and abs(q-11)<1.5)'
- check: abs(p-13)<0.5 and abs(q-11)<0.5
diff --git a/content/lessons/data/bits-bytes-and-data-sizes/ar.md b/content/lessons/data/bits-bytes-and-data-sizes/ar.md
index 282957a1..67914fb8 100644
--- a/content/lessons/data/bits-bytes-and-data-sizes/ar.md
+++ b/content/lessons/data/bits-bytes-and-data-sizes/ar.md
@@ -19,7 +19,7 @@ variables:
1. **حرف واحد.** كتابة حرف واحد تكلّف حاسوبك بايتًا واحدًا تقريبًا، فيكون e عند 0.
2. **صورة من الجوال.** صورة عادية من الجوال حجمها بضعة ميجابايتات، فيكون e قرابة 6.6، أي نحو 4,000,000 بايت.
-3. **بيانات العالم كله في سنة.** يسجّل البشر كل فيديو ورسالة وقراءة حسّاس في سنة واحدة. يزيد مجموع هذه البايتات كثيرًا على رقم 1 وبعده 21 صفرًا، فيصعد e إلى آخر المنزلق، قريبًا من 22.
+3. **بيانات العالم كله في سنة.** يسجّل البشر كل فيديو ورسالة وقراءة حسّاس في سنة واحدة. يزيد مجموع هذه البايتات على 100 ZB، أي رقم 1 وبعده 23 صفرًا، فيصعد e إلى آخر المنزلق تمامًا، عند 23.
## Test yourself
diff --git a/content/lessons/data/bits-bytes-and-data-sizes/en.md b/content/lessons/data/bits-bytes-and-data-sizes/en.md
index 339b9ccb..bf1cb54f 100644
--- a/content/lessons/data/bits-bytes-and-data-sizes/en.md
+++ b/content/lessons/data/bits-bytes-and-data-sizes/en.md
@@ -18,7 +18,7 @@ variables:
1. **A single letter.** One typed character costs about one byte to store, so e sits at 0.
2. **A phone photo.** A typical phone photo is a few megabytes, so e sits around 6.6, about 4,000,000 bytes.
-3. **All the world's data in a year.** Every video, message and sensor reading humanity records in a year adds up to well over a 1 followed by 21 zeros in bytes, so e climbs to the top of the slider, close to 22.
+3. **All the world's data in a year.** Every video, message and sensor reading humanity records in a year adds up to more than 100 ZB, a 1 followed by 23 zeros in bytes, so e climbs to the very top of the slider, 23.
## Test yourself
diff --git a/content/lessons/data/bits-bytes-and-data-sizes/lesson.yaml b/content/lessons/data/bits-bytes-and-data-sizes/lesson.yaml
index dc5e08e4..f5d2d3ec 100644
--- a/content/lessons/data/bits-bytes-and-data-sizes/lesson.yaml
+++ b/content/lessons/data/bits-bytes-and-data-sizes/lesson.yaml
@@ -21,7 +21,7 @@ primary: e
parameters:
e:
min: 0
- max: 22
+ max: 23
step: 0.1
value: 3
variables:
@@ -34,7 +34,7 @@ derivation:
presets:
- e: 0
- e: 6.6
- - e: 21.9
+ - e: 23
challenges:
- check: e
target: 9
diff --git a/content/lessons/discrete/graphs-and-euler-paths/ar.md b/content/lessons/discrete/graphs-and-euler-paths/ar.md
index a42bc9a1..9ed3b98d 100644
--- a/content/lessons/discrete/graphs-and-euler-paths/ar.md
+++ b/content/lessons/discrete/graphs-and-euler-paths/ar.md
@@ -41,7 +41,7 @@ variables:
## Advanced
-توضح حجة أزواج الحواف لماذا يلزم شرط الدرجات. ولإثبات كفايته، يمكن بناء مسارات ودمج المسارات المغلقة فيها حتى نستخدم جميع الحواف. شرط الاتصال ضروري: لدورتين منفصلتين درجات زوجية كلها، لكن لا يمكن اجتيازهما بمسار واحد. أما البحث بالعرض المعروض هنا فيقلل عدد الحواف للوصول إلى الرؤوس؛ ومجموع الأوزان الذي يعرضه ليس بالضرورة أقل مجموع ممكن.
+توضح حجة أزواج الحواف لماذا يلزم شرط الدرجات. ولإثبات كفايته، يمكن بناء مسارات ودمج المسارات المغلقة فيها حتى نستخدم جميع الحواف. شرط الاتصال ضروري: لدورتين منفصلتين درجات زوجية كلها، لكن لا يمكن اجتيازهما بمسار واحد. أما البحث بالعرض المعروض هنا فيقلل عدد الحواف للوصول إلى الرؤوس؛ والرقم الذي يعرضه بجانب كل رأس يعدّ الحواف ولا يأخذ الأوزان في الحساب.
## Derivation
diff --git a/content/lessons/discrete/graphs-and-euler-paths/en.md b/content/lessons/discrete/graphs-and-euler-paths/en.md
index bc51cce8..3518049b 100644
--- a/content/lessons/discrete/graphs-and-euler-paths/en.md
+++ b/content/lessons/discrete/graphs-and-euler-paths/en.md
@@ -41,7 +41,7 @@ For a finite undirected graph with at least one edge, an Euler trail exists exac
## Advanced
-The pairing argument explains why the degree condition is necessary. To show sufficiency, one can build trails and splice closed trails into them until every edge is used. Connectivity is essential: two separate cycles have only even degrees, yet no single trail can cover both. The breadth-first search shown here minimizes edge count to reachable vertices; its displayed accumulated weights need not be minimum-weight distances.
+The pairing argument explains why the degree condition is necessary. To show sufficiency, one can build trails and splice closed trails into them until every edge is used. Connectivity is essential: two separate cycles have only even degrees, yet no single trail can cover both. The breadth-first search shown here minimizes edge count to reachable vertices; the number it shows beside each vertex counts edges and ignores the weights.
## Derivation
diff --git a/content/lessons/networking/nas-and-raid/ar.md b/content/lessons/networking/nas-and-raid/ar.md
index 8daaf59e..2332409e 100644
--- a/content/lessons/networking/nas-and-raid/ar.md
+++ b/content/lessons/networking/nas-and-raid/ar.md
@@ -42,7 +42,7 @@ variables:
في وضع التكافؤ تحصل كل مجموعة من كتل البيانات على كتلة تكافؤ تُحسب بـXOR: $P = b_1 \oplus b_2 \oplus \cdots$، ولأن تطبيق XOR مرتين يلغي أثره، فأي كتلة ضائعة تساوي XOR كل البقية — وهذا هو إعادة الحساب الذي تشاهده في المحاكاة.
-والسعات تتبع مباشرة: التقسيم يستعمل كل شيء، $U = ns$؛ والمرآة تضاعف كل شيء، $U = \frac{ns}{2}$؛ والتكافؤ يحجز مساحة قرص واحد، $U = (n-1)s$. التقسيم وحده يرسب في اختبار القرص الميت الواحد؛ والمرآة والتكافؤ كلاهما ينجح، بثمنين مختلفين.
+والسعات تتبع مباشرة: التقسيم يستعمل كل شيء، $U = ns$؛ والمرآة تضاعف كل شيء، $U = \frac{ns}{2}$؛ والتكافؤ يحجز مساحة قرص واحد، $U = (n-1)s$. وإذا كان عدد الأقراص فرديًّا بقي في المرآة قرص بلا توأم فيظل فارغًا: 5 أقراص من 4 TB تعطي في المرآة 8 TB لا 10. التقسيم وحده يرسب في اختبار القرص الميت الواحد؛ والمرآة والتكافؤ كلاهما ينجح، بثمنين مختلفين.
## Advanced
diff --git a/content/lessons/networking/nas-and-raid/en.md b/content/lessons/networking/nas-and-raid/en.md
index 0f249f08..cb3fc396 100644
--- a/content/lessons/networking/nas-and-raid/en.md
+++ b/content/lessons/networking/nas-and-raid/en.md
@@ -43,7 +43,7 @@ Stripe scatters each file's blocks across all the disks — every byte bought is
In parity mode each group of data blocks gets one parity block computed with XOR: $P = b_1 \oplus b_2 \oplus \cdots$, and because XOR undoes itself, any one lost block equals the XOR of all the others — the recomputation you watch in the sim.
-The capacities follow directly: stripe uses everything, $U = ns$; mirror duplicates everything, $U = \frac{ns}{2}$; parity reserves one disk's worth, $U = (n-1)s$. Only stripe fails the one-dead-disk test; mirror and parity both pass it, at different prices.
+The capacities follow directly: stripe uses everything, $U = ns$; mirror duplicates everything, $U = \frac{ns}{2}$; parity reserves one disk's worth, $U = (n-1)s$. With an odd number of disks the mirror leaves one disk without a twin, so it stays empty: 5 disks of 4 TB mirror to 8 TB, not 10. Only stripe fails the one-dead-disk test; mirror and parity both pass it, at different prices.
## Advanced
diff --git a/content/ui/ar.yaml b/content/ui/ar.yaml
index eb848d76..db5c1b1a 100644
--- a/content/ui/ar.yaml
+++ b/content/ui/ar.yaml
@@ -262,6 +262,7 @@ gates.out: المُخرَج
gates.table: جدول الحقيقة
sort.step: الخطوة
sort.compares: المقارنات
+sort.reads: القراءات
sort.swaps: التبديلات
sort.done: مرتّب
sort.hint: ▶ شغّل الخوارزمية · اسحب المنزلق للتقدّم خطوة خطوة
diff --git a/content/ui/ar/compression-entropy.yaml b/content/ui/ar/compression-entropy.yaml
index 8c060ec3..7916804f 100644
--- a/content/ui/ar/compression-entropy.yaml
+++ b/content/ui/ar/compression-entropy.yaml
@@ -8,3 +8,4 @@ ce.fixedBits: بتّات ثابتة لكل رمز
ce.smallerBy: أصغر بنسبة
ce.run: التكرار
ce.count: العدد
+ce.bits: بت
diff --git a/content/ui/ar/join-tables.yaml b/content/ui/ar/join-tables.yaml
index 9f13cc0b..43eab29e 100644
--- a/content/ui/ar/join-tables.yaml
+++ b/content/ui/ar/join-tables.yaml
@@ -18,3 +18,5 @@ jt.sara: سارة
jt.omar: عمر
jt.lina: لينا
jt.yousef: يوسف
+jt.cust: عميل
+jt.money: '{n} ريال'
diff --git a/content/ui/en.yaml b/content/ui/en.yaml
index 9287ec17..c3aa9101 100644
--- a/content/ui/en.yaml
+++ b/content/ui/en.yaml
@@ -262,6 +262,7 @@ gates.out: output
gates.table: truth table
sort.step: step
sort.compares: comparisons
+sort.reads: reads
sort.swaps: swaps
sort.done: sorted
sort.hint: ▶ runs the algorithm · drag the slider to step through
diff --git a/content/ui/en/compression-entropy.yaml b/content/ui/en/compression-entropy.yaml
index cc0e23b6..96811b31 100644
--- a/content/ui/en/compression-entropy.yaml
+++ b/content/ui/en/compression-entropy.yaml
@@ -8,3 +8,4 @@ ce.fixedBits: fixed-length bits per symbol
ce.smallerBy: smaller by
ce.run: run
ce.count: count
+ce.bits: bits
diff --git a/content/ui/en/join-tables.yaml b/content/ui/en/join-tables.yaml
index d30bd4cd..f0ddf397 100644
--- a/content/ui/en/join-tables.yaml
+++ b/content/ui/en/join-tables.yaml
@@ -18,3 +18,5 @@ jt.sara: Sara
jt.omar: Omar
jt.lina: Lina
jt.yousef: Yousef
+jt.cust: cust
+jt.money: '${n}'
diff --git a/src/viz/ai/NeuralNet.vue b/src/viz/ai/NeuralNet.vue
index 3ef0e1f2..63220998 100644
--- a/src/viz/ai/NeuralNet.vue
+++ b/src/viz/ai/NeuralNet.vue
@@ -13,7 +13,7 @@ const H = 480
const p = (k: string, d = 0) => props.params[k] ?? d
const sig = (z: number) => 1 / (1 + Math.exp(-z))
function forward(x: number, y: number) {
- const h = [Math.tanh(p('w11', 1) * x + p('w12', 1) * y), Math.tanh(p('w21', 1) * x - p('w22', 1) * y), Math.tanh(p('w31', -1) * x + p('w32', 1) * y)]
+ const h = [Math.tanh(p('w11', 1) * x + p('w12', 1) * y), Math.tanh(p('w21', 1) * x + p('w22', -1) * y), Math.tanh(p('w31', -1) * x + p('w32', 1) * y)]
const out = sig(p('v1', 1) * h[0] + p('v2', 1) * h[1] + p('v3', 1) * h[2] + p('b', 0))
return { h, out }
}
@@ -29,7 +29,7 @@ const mx = (x: number) => map.x + ((x + 3) / 6) * 24 * map.s
const my = (y: number) => map.y + ((3 - y) / 6) * 24 * map.s
const nodes = { in: [[60, 160], [60, 320]], hid: [[220, 100], [220, 240], [220, 380]], out: [[380, 240]] }
const wts = computed(() => [
- ...[['w11', 0, 0], ['w12', 1, 0], ['w21', 0, 1], ['w22', 1, 1], ['w31', 0, 2], ['w32', 1, 2]].map(([k, i, h]) => ({ x1: nodes.in[i as number][0], y1: nodes.in[i as number][1], x2: nodes.hid[h as number][0], y2: nodes.hid[h as number][1], w: p(k as string, 1) * (k === 'w22' ? -1 : 1) })),
+ ...[['w11', 0, 0], ['w12', 1, 0], ['w21', 0, 1], ['w22', 1, 1], ['w31', 0, 2], ['w32', 1, 2]].map(([k, i, h]) => ({ x1: nodes.in[i as number][0], y1: nodes.in[i as number][1], x2: nodes.hid[h as number][0], y2: nodes.hid[h as number][1], w: p(k as string, 1) })),
...['v1', 'v2', 'v3'].map((k, h) => ({ x1: nodes.hid[h][0], y1: nodes.hid[h][1], x2: nodes.out[0][0], y2: nodes.out[0][1], w: p(k, 1) })),
])
const readouts = computed(() => [
diff --git a/src/viz/ai/PolyFit.vue b/src/viz/ai/PolyFit.vue
index 2c531521..5553a987 100644
--- a/src/viz/ai/PolyFit.vue
+++ b/src/viz/ai/PolyFit.vue
@@ -46,11 +46,13 @@ const path = (f: (x: number) => number) => Array.from({ length: 201 }, (_, i) =>
const mse = (xs: [number, number][]) => xs.reduce((s, [x, y]) => s + (model(x) - y) ** 2, 0) / xs.length
const trainErr = computed(() => mse(pts.value))
const testErr = computed(() => mse(test.map((x) => [x, truth(x)] as [number, number])))
+// overfitting = far worse on new points than on the training points AND worse than a flat line (error ≈ 2)
+const over = computed(() => testErr.value > 3 * trainErr.value + 0.2 && testErr.value > 2)
const readouts = computed(() => [
{ label: t('fit.degree'), value: String(degree.value) },
{ label: t('fit.trainErr'), value: fmt(trainErr.value, 3), color: 'var(--accent)' },
- { label: t('fit.testErr'), value: fmt(testErr.value, 3), color: testErr.value > 3 * trainErr.value + 0.2 ? 'var(--neg)' : 'var(--pos)' },
- { label: t('fit.verdict'), value: degree.value <= 1 ? t('fit.under') : testErr.value > 3 * trainErr.value + 0.2 ? t('fit.over') : t('fit.good') },
+ { label: t('fit.testErr'), value: fmt(testErr.value, 3), color: over.value ? 'var(--neg)' : 'var(--pos)' },
+ { label: t('fit.verdict'), value: degree.value <= 1 ? t('fit.under') : over.value ? t('fit.over') : t('fit.good') },
])
function add(e: PointerEvent) {
const svg = e.currentTarget as SVGSVGElement
diff --git a/src/viz/ai/Tokenizer.vue b/src/viz/ai/Tokenizer.vue
index 0054c922..19998dde 100644
--- a/src/viz/ai/Tokenizer.vue
+++ b/src/viz/ai/Tokenizer.vue
@@ -18,7 +18,7 @@ const TEXTS = [
'القطة جلست على السجادة لأن القطة كانت متعبة',
]
const textIx = computed(() => Math.min(Math.max(Math.round(props.params.text ?? 0), 0), 2))
-const merges = computed(() => Math.min(Math.max(Math.round(props.params.merges ?? 0), 0), 30))
+const merges = computed(() => Math.min(Math.max(Math.round(props.params.merges ?? 0), 0), 6))
const sample = computed(() => TEXTS[textIx.value])
// byte-pair encoding: words become char lists, then the most frequent adjacent pair merges, m times
diff --git a/src/viz/computer-science/SortSteps.vue b/src/viz/computer-science/SortSteps.vue
index c9345126..9cdde3d8 100644
--- a/src/viz/computer-science/SortSteps.vue
+++ b/src/viz/computer-science/SortSteps.vue
@@ -195,7 +195,7 @@ const bw = computed(() => (W - 40) / n.value)
const readouts = computed(() => [
{ label: t('sort.algorithm'), value: t(`sort.alg.${algName.value}` as any), color: 'var(--fg)' },
{ label: t('sort.step'), value: `${fi.value} / ${trace.value.length - 1}` },
- { label: t('sort.compares'), value: String(compares.value), color: 'var(--accent)' },
+ { label: t(algName.value === 'counting' || algName.value === 'radix' ? 'sort.reads' : 'sort.compares'), value: String(compares.value), color: 'var(--accent)' },
{ label: t('sort.swaps'), value: String(swaps.value), color: 'var(--accent-2)' },
{ label: 'n', value: String(n.value) },
])
diff --git a/src/viz/cryptography/LatticeCrypto.vue b/src/viz/cryptography/LatticeCrypto.vue
index c18b5df4..fd7abc2b 100644
--- a/src/viz/cryptography/LatticeCrypto.vue
+++ b/src/viz/cryptography/LatticeCrypto.vue
@@ -38,6 +38,18 @@ const best = computed(() => {
const found = computed(() => Math.hypot(babai.value.x - tx.value, babai.value.y - ty.value))
const hit = computed(() => Math.abs(found.value - best.value.d) < 1e-9)
const points = computed(() => { const out: { x: number; y: number }[] = []; for (let i = -10; i <= 10; i++) for (let j = -10; j <= 10; j++) { const x = i * 2 + j; const y = i + j * 2; if (Math.abs(x) <= 9.6 && Math.abs(y) <= 5.6) out.push({ x, y }) } return out })
+// where to draw Babai's ring: the rounded point itself, or, if that is outside the picture, the spot
+// where the line towards it leaves the picture (its true coordinates are then written beside it)
+const shown = computed(() => {
+ const ax = px(tx.value), ay = py(ty.value), bx = px(babai.value.x), by = py(babai.value.y)
+ let k = 1
+ if (bx < 14) k = Math.min(k, (14 - ax) / (bx - ax))
+ if (bx > W - 14) k = Math.min(k, (W - 14 - ax) / (bx - ax))
+ if (by < 40) k = Math.min(k, (40 - ay) / (by - ay))
+ if (by > H - 34) k = Math.min(k, (H - 34 - ay) / (by - ay))
+ k = Math.max(0, k)
+ return { x: ax + k * (bx - ax), y: ay + k * (by - ay), off: k < 1 }
+})
const svg = ref()
const dragging = ref(false)
function pick(e: PointerEvent) {
@@ -67,8 +79,9 @@ const readouts = computed(() => [
{{ i ? 'v' : 'u' }} ({{ v[0] }}, {{ v[1] }})
-
-
+
+
+ → ({{ babai.x }}, {{ babai.y }})
{{ t('lattice.actual') }}
diff --git a/src/viz/data/CompressionEntropy.vue b/src/viz/data/CompressionEntropy.vue
index 49519cc4..86f9ea08 100644
--- a/src/viz/data/CompressionEntropy.vue
+++ b/src/viz/data/CompressionEntropy.vue
@@ -79,7 +79,7 @@ const barY = (i: number) => 90 + i * 90
{{ SYMS[s] }} × {{ reps }}
- {{ originalBits }} bits → {{ compressedBits }} bits
+ {{ originalBits }} {{ t('ce.bits') }} → {{ compressedBits }} {{ t('ce.bits') }}
diff --git a/src/viz/data/JoinTables.vue b/src/viz/data/JoinTables.vue
index ee214a28..b56eda7b 100644
--- a/src/viz/data/JoinTables.vue
+++ b/src/viz/data/JoinTables.vue
@@ -52,7 +52,7 @@ const readouts = computed(() => [
{{ t('jt.orders') }}
- #{{ o.oid }} · cust {{ o.cust }} · ${{ o.amount }}
+ #{{ o.oid }} · {{ t('jt.cust') }} {{ o.cust }} · {{ t('jt.money', { n: o.amount }) }}
@@ -74,7 +74,7 @@ const readouts = computed(() => [
{{ r.cust }}
{{ t(`jt.${r.name}` as any) }}
{{ r.oid ?? 'NULL' }}
- {{ r.amount === null ? 'NULL' : '$' + r.amount }}
+ {{ r.amount === null ? 'NULL' : t('jt.money', { n: r.amount }) }}
diff --git a/src/viz/networking/NasRaid.vue b/src/viz/networking/NasRaid.vue
index 692e6b06..17e8737c 100644
--- a/src/viz/networking/NasRaid.vue
+++ b/src/viz/networking/NasRaid.vue
@@ -6,7 +6,7 @@ import Readouts from '../../components/Readouts.vue'
// networking/nas-and-raid. params n (disks), s (TB per disk), mode (0 stripe, 1 mirror, 2 parity),
// dead (kill disk 1). One family-photo file is spread across the bays; pull a disk and watch which
-// layout shrugs it off. Usable space: stripe ns, mirror ns/2, parity (n−1)s.
+// layout shrugs it off. Usable space: stripe ns, mirror ⌊n/2⌋·s (an odd disk has no twin and stays empty), parity (n−1)s.
const props = defineProps<{ params: Record; options: Record }>()
defineEmits<{ set: [name: string, value: number] }>()
const W = 800
@@ -16,7 +16,7 @@ const s = computed(() => Math.min(Math.max(Math.round(props.params.s ?? 4), 1),
const mode = computed(() => Math.min(Math.max(Math.round(props.params.mode ?? 2), 0), 2))
const dead = computed(() => Math.round(props.params.dead ?? 0) >= 1)
const raw = computed(() => n.value * s.value)
-const usable = computed(() => (mode.value === 0 ? raw.value : mode.value === 1 ? raw.value / 2 : (n.value - 1) * s.value))
+const usable = computed(() => (mode.value === 0 ? raw.value : mode.value === 1 ? Math.floor(n.value / 2) * s.value : (n.value - 1) * s.value))
const survives = computed(() => mode.value !== 0)
const modeName = computed(() => (mode.value === 0 ? t('nas.stripe') : mode.value === 1 ? t('nas.mirror') : t('nas.parity')))
diff --git a/src/viz/shared/GraphSearch.vue b/src/viz/shared/GraphSearch.vue
index ae465d04..362ba730 100644
--- a/src/viz/shared/GraphSearch.vue
+++ b/src/viz/shared/GraphSearch.vue
@@ -40,6 +40,7 @@ const trace = computed(() => {
rec(open, u)
}
} else {
+ // BFS/DFS ignore the edge weights: the number beside a node counts steps (edges) from the start.
const open = [start.value]
const seen = new Set([start.value])
rec(open, -1)
@@ -47,7 +48,18 @@ const trace = computed(() => {
const u = alg === 'bfs' ? open.shift()! : open.pop()!
visited.push(u)
rec(open, u)
- for (const { to, w } of adj[u]) if (!seen.has(to)) seen.add(to), (parent[to] = u), (dist[to] = dist[u] + w), open.push(to)
+ if (alg === 'bfs') {
+ for (const { to } of adj[u]) if (!seen.has(to)) seen.add(to), (parent[to] = u), (dist[to] = dist[u] + 1), open.push(to)
+ } else {
+ // DFS: a node counts as seen only when visited; a waiting node found again moves to the top of the stack
+ for (const { to } of adj[u]) if (!visited.includes(to)) {
+ const k = open.indexOf(to)
+ if (k >= 0) open.splice(k, 1)
+ parent[to] = u
+ dist[to] = dist[u] + 1
+ open.push(to)
+ }
+ }
rec(open, u)
}
}
@@ -63,7 +75,7 @@ const pathTo = computed(() => {
return out[0] === start.value ? out : []
})
const onPath = (a: number, b: number) => done.value && pathTo.value.some((v, i) => i && ((pathTo.value[i - 1] === a && v === b) || (pathTo.value[i - 1] === b && v === a)))
-const pathLen = computed(() => (pathTo.value.length ? pathTo.value.slice(1).reduce((s, v, i) => s + edges.find((e) => (e[0] === pathTo.value[i] && e[1] === v) || (e[1] === pathTo.value[i] && e[0] === v))![2], 0) : NaN))
+const pathLen = computed(() => (!pathTo.value.length ? NaN : (props.options.algorithm ?? 'bfs') !== 'dijkstra' ? pathTo.value.length - 1 : pathTo.value.slice(1).reduce((s, v, i) => s + edges.find((e) => (e[0] === pathTo.value[i] && e[1] === v) || (e[1] === pathTo.value[i] && e[0] === v))![2], 0)))
const readouts = computed(() => [
{ label: t('gsearch.visited'), value: `${f.value.visited.length} / 10`, color: 'var(--pos)' },
diff --git a/src/viz/shared/PowersOfTen.vue b/src/viz/shared/PowersOfTen.vue
index 9c4c2a6b..50628762 100644
--- a/src/viz/shared/PowersOfTen.vue
+++ b/src/viz/shared/PowersOfTen.vue
@@ -16,10 +16,10 @@ const sets: Record
Date: Wed, 25 Nov 2026 11:49:37 +0300
Subject: [PATCH 10/10] fix: layout and label problems found in a browser check
of the visualizations
---
content/ui/ar.yaml | 2 ++
content/ui/en.yaml | 2 ++
src/viz/electromagnetism/ElectricField.vue | 2 +-
src/viz/electromagnetism/GeneratorsAndAc.vue | 4 ++--
src/viz/engineering/LoudnessLadder.vue | 2 +-
src/viz/shared/GraphSearch.vue | 4 ++--
6 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/content/ui/ar.yaml b/content/ui/ar.yaml
index db5c1b1a..8cb4cdbd 100644
--- a/content/ui/ar.yaml
+++ b/content/ui/ar.yaml
@@ -284,6 +284,8 @@ gsearch.frontier: في الطابور
gsearch.pathLen: طول المسار
gsearch.hint: اضغط عقدة لاختيار البداية · الأرقام على الأضلاع مسافات
gsearch.order: ترتيب الزيارة
+gsearch.start: البداية
+gsearch.goal: الهدف
bits.hint: اضغط خانة لتقلبها
bits.dec: عشري
bits.hex: ست عشري
diff --git a/content/ui/en.yaml b/content/ui/en.yaml
index c3aa9101..426bdf0c 100644
--- a/content/ui/en.yaml
+++ b/content/ui/en.yaml
@@ -284,6 +284,8 @@ gsearch.frontier: in the queue
gsearch.pathLen: path length
gsearch.hint: tap a node to choose the start · numbers on edges are distances
gsearch.order: visit order
+gsearch.start: start
+gsearch.goal: goal
bits.hint: tap a bit to flip it
bits.dec: decimal
bits.hex: hexadecimal
diff --git a/src/viz/electromagnetism/ElectricField.vue b/src/viz/electromagnetism/ElectricField.vue
index 97a58e6e..84221a96 100644
--- a/src/viz/electromagnetism/ElectricField.vue
+++ b/src/viz/electromagnetism/ElectricField.vue
@@ -67,7 +67,7 @@ const potential = computed(
const arrows = computed(() => {
const out: { x1: number; y1: number; x2: number; y2: number; head: string; op: number }[] = []
for (let gx = 20; gx <= W - 20; gx += 40) {
- for (let gy = 20; gy <= H - 20; gy += 40) {
+ for (let gy = 60; gy <= H - 20; gy += 40) {
const { ex, ey } = eAt(wx(gx), wy(gy))
const mag = Math.hypot(ex, ey)
if (!Number.isFinite(mag) || mag < 1e-6) continue
diff --git a/src/viz/electromagnetism/GeneratorsAndAc.vue b/src/viz/electromagnetism/GeneratorsAndAc.vue
index c143ca95..e7beff69 100644
--- a/src/viz/electromagnetism/GeneratorsAndAc.vue
+++ b/src/viz/electromagnetism/GeneratorsAndAc.vue
@@ -15,8 +15,8 @@ const W = 800
const H = 480
const X0 = 80
const X1 = 730
-const Y0 = 380
-const AMP_PX = 130
+const Y0 = 335
+const AMP_PX = 110
const T_MAX = 0.1
const N = computed(() => Math.max(props.params.N ?? 100, 1))
diff --git a/src/viz/engineering/LoudnessLadder.vue b/src/viz/engineering/LoudnessLadder.vue
index 3713f1a9..760275f7 100644
--- a/src/viz/engineering/LoudnessLadder.vue
+++ b/src/viz/engineering/LoudnessLadder.vue
@@ -46,7 +46,7 @@ const readouts = computed(() => [
0 … 1,000,000
- {{ t('db.linearNote') }}
+ {{ t('db.linearNote') }}
{{ t('db.ladder') }}
diff --git a/src/viz/shared/GraphSearch.vue b/src/viz/shared/GraphSearch.vue
index 362ba730..27c2ce7f 100644
--- a/src/viz/shared/GraphSearch.vue
+++ b/src/viz/shared/GraphSearch.vue
@@ -99,8 +99,8 @@ const readouts = computed(() => [
{{ String.fromCharCode(65 + i) }}
{{ f.dist[i] }}
- start
- goal
+ {{ t('gsearch.start') }}
+ {{ t('gsearch.goal') }}