Skip to content

Commit 5aaa0d2

Browse files
authored
Stefans Law and the greek letters (#201)
1 parent 57236d3 commit 5aaa0d2

File tree

4 files changed

+412
-24
lines changed

4 files changed

+412
-24
lines changed

src/mentat_collective/emmy/fdg_ch01_ys.clj

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:date "2025-11-19"
88
:image "fdg_ch01_ys.jpg"
99
:category :libs
10-
:tags [:emmy :infix :yamlscript]}}}
10+
:tags [:emmy :infix :yamlscript :notation]}}}
1111

1212
(ns mentat-collective.emmy.fdg-ch01-ys
1313
(:refer-clojure :exclude [+ - * / zero? compare divide numerator denominator
@@ -78,30 +78,28 @@
7878

7979
(ys "
8080
defn LFree(mass):
81-
fn([_ _ v]): mass * 1/2 * square(v)
81+
fn([_ _ v]): 1/2 * mass * square(v)
8282
")
8383

8484
;; ## Another one
8585

86-
;; I proceed to the next infix snippet
86+
(kind/scittle
87+
'(defn sphere->R3 [R]
88+
(fn [[_ [theta phi]]]
89+
(up (* R (sin theta) (cos phi))
90+
(* R (sin theta) (sin phi))
91+
(* R (cos theta))))))
8792

8893
(ys "
8994
defn sphere-to-R3(R):
9095
fn([_ [theta phi]]):
9196
up:
92-
=>: R * sin(theta) * cos(phi)
93-
=>: R * sin(theta) * sin(phi)
94-
=>: R * cos(theta)
97+
R *: sin(theta) * cos(phi)
98+
R *: sin(theta) * sin(phi)
99+
R *: cos(theta)
95100
")
96101

97-
;; which is the following in Clojure
98-
99-
(kind/scittle
100-
'(defn sphere->R3 [R]
101-
(fn [[_ [theta phi]]]
102-
(up (* R (sin theta) (cos phi))
103-
(* R (sin theta) (sin phi))
104-
(* R (cos theta))))))
102+
;; The `*:` means nothing but normal multiplication.
105103

106104
;; ## Higher order functions
107105

@@ -120,10 +118,12 @@ defn F-to-C(F):
120118
up:
121119
time: state
122120
F: state
123-
=>: D(0).of(F).at(state) + ( D(1).of(F).at(state) * velocity(state) )
121+
D(0).of(F).at(state) +:
122+
D(1).of(F).at(state) *
123+
velocity(state)
124124
")
125125

126-
;; With `of` and `at` like that, the above `D(0).of(F).at(state)` (which means "take the zeroth derivative of the function F at point state") translates into what are higher order functions in the Clojure version.
126+
;; Again, the above `+:` is normal addition. With `of` and `at` like that, the above `D(0).of(F).at(state)` (which means "take the zeroth derivative of the function F at point state") translates into what are higher order functions in the Clojure version.
127127

128128
(kind/scittle
129129
'(defn F->C [F]
@@ -145,13 +145,15 @@ defn Lsphere(m R):
145145

146146
(kind/scittle
147147
'(defn Lsphere [m R]
148-
(compose (Lfree m) (F->C (sphere->R3 R)))))
148+
(compose (Lfree m)
149+
(F->C (sphere->R3 R)))))
149150

150151
;; ## The proof is in the pudding
151152

152-
;; In order to quote symbols, I introduce a macro called `q`
153+
;; Emmy is a symbolic algebra system, `m:q` produces a symbol named `m`.
153154

154-
(defmacro q [f] (list 'quote f))
155+
^:kindly/hide-code
156+
(defmacro q [s] (list 'quote s))
155157

156158
(ys "
157159
simplify:
@@ -166,7 +168,9 @@ simplify:
166168
(vector :tt
167169
'(simplify
168170
((Lsphere 'm 'R)
169-
(up 't (up 'theta 'phi) (up 'thetadot 'phidot))))))
171+
(up 't
172+
(up 'theta 'phi)
173+
(up 'thetadot 'phidot))))))
170174

171175
;; Indeed the results are the same which proves the infix technically works.
172176

@@ -192,12 +196,18 @@ yamlscript/core {:git/url \"https://github.com/yaml/yamlscript\"
192196
;; ## 1
193197
(ys "
194198
defn L2(mass metric):
195-
fn(place velocity): mass * 1/2 * metric(velocity velocity).at(place)
199+
fn(place velocity):
200+
1/2 *:
201+
mass *
202+
metric(velocity velocity).at(place)
196203
")
204+
197205
(kind/scittle
198206
'(defn L2 [mass metric]
199207
(fn [place velocity]
200-
(* 1/2 mass ((metric velocity velocity) place)))))
208+
(* 1/2
209+
mass
210+
((metric velocity velocity) place)))))
201211

202212

203213
;; ## 2
@@ -209,9 +219,11 @@ defn L2(mass metric):
209219
defn Lc(mass metric coordsys):
210220
e =: coordinate-system-to-vector-basis(coordsys)
211221
fn([_ x v]):
212-
L2(mass metric): point(coordsys).at(x) (e * v)
222+
L2(mass metric): point(coordsys).at(x), (e * v)
213223
")
214224

225+
;; The `,` above is a matter of taste and can also be omitted
226+
215227
(kind/scittle
216228
'(defn Lc [mass metric coordsys]
217229
(let [e (coordinate-system->vector-basis coordsys)]
@@ -251,4 +263,6 @@ simplify:
251263
(kind/reagent
252264
(vector :tt
253265
'(simplify
254-
(L (up 't (up 'x 'y) (up 'vx 'vy))))))
266+
(L (up 't
267+
(up 'x 'y)
268+
(up 'vx 'vy))))))
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
^{:kindly/hide-code true
2+
:clay {:title "How to pronounce greek letters"
3+
:quarto {:author :kloimhardt
4+
:type :post
5+
:description "Josef Stefan's fourth-power law, written in both greek and english."
6+
:date "2025-11-27"
7+
:image "josefstefan.png"
8+
:category :libs
9+
:tags [:emmy :physics :notation]}}}
10+
(ns mentat-collective.emmy.josefstefan
11+
(:refer-clojure :exclude [+ - * / = abs compare zero? ref partial
12+
times numerator denominator infinite?])
13+
(:require [emmy.env :as e :refer :all :exclude [F->C times]]
14+
[mentat-collective.emmy.spell :refer :all]
15+
[scicloj.kindly.v4.api :as kindly]
16+
[scicloj.kindly.v4.kind :as kind]))
17+
18+
;; The greek letters $\xi$ ("xi"), $\eta$ ("eta") and $\zeta$ ("zeta") are often used in textbooks as counterparts to the latin x,y and z. This needs practice. All the more so that there also are the two greeks $\chi$ ("chi") and $\omega$ ("omega").
19+
20+
;; I'd like to make a table for this:
21+
22+
^:kindly/hide-code
23+
(kind/table
24+
[["xi" (kind/md "$\\xi$")]
25+
["eta" (kind/md "$\\eta$")]
26+
["zeta" (kind/md "$\\zeta$")]
27+
["chi" (kind/md "$\\chi$")]
28+
["omega" (kind/md "$\\omega$")]]
29+
)
30+
31+
;; For practice, I start with a widely forgotten formula by Messieurs Dulong and Petit
32+
33+
^:kindly/hide-code
34+
(def tex (comp kind/tex emmy.expression.render/->TeX))
35+
36+
^:kindly/hide-code
37+
(defn dp-formel2 [Celsius constants]
38+
(calcbox [((((eta power xi) minus 1) times zeta)
39+
with
40+
[xi in Celsius])
41+
[and [[eta zeta] being constants]]]))
42+
43+
^:kindly/hide-code
44+
(def greek-alphabet {:eta 'eta :zeta 'zeta :chi 'chi :omega 'omega})
45+
46+
^:kindly/hide-code
47+
(tex (:calc (dp-formel2 'xi greek-alphabet)))
48+
49+
;; How on earth do you pronounce that? Here we go
50+
51+
^:kindly/hide-code
52+
(kind/hiccup [:blockquote (:hiccup (dp-formel2 0 greek-alphabet))])
53+
54+
;; Included is the hint that the xi-$\xi$ is a temperature measured in degree Celsius. But what are the constants eta-$\eta$ and zeta-$\zeta$?
55+
56+
;; ## The formula of Dulong&Petit
57+
58+
;; I define a function which includes the sought-for numbers
59+
60+
(defn dp-formula [Celsius]
61+
(calcbox [((((eta power xi) minus 1) times zeta)
62+
with
63+
[xi in Celsius])
64+
[and [(1 comma 0 0 77) for eta]]
65+
[and [(2 comma 0 2) for zeta]]]))
66+
67+
;; This reads as
68+
69+
(kind/hiccup [:blockquote (:hiccup (dp-formula 0))])
70+
71+
;; The formula prints like this
72+
73+
(tex (:calc (dp-formula 'xi)))
74+
75+
;; I can now also calculate a number, e.g. for 100 °C
76+
77+
(:calc (dp-formula 100))
78+
79+
;; But what does this number mean? It is degrees per minute. In 1817, Dulong and Petit measured the rate of change with time of the indicated temperature on a previously heated mercury-in-glass thermometer with a spherical bulb placed centrally in a spherical enclosure held at zero degrees Celsius.
80+
81+
;; These were their measured values
82+
83+
^:kindly/hide-code
84+
(def temper [80 100 120 140 160 180 200 220 240])
85+
86+
^:kindly/hide-code
87+
(def dp-meas [1.74 2.30 3.02 3.88 4.89 6.10 7.40 8.81 10.69])
88+
89+
^:kindly/hide-code
90+
(kind/table
91+
{"°C" temper
92+
"°C / min" dp-meas})
93+
94+
;; So, when the thermometer was at 100°C, within the first minute it lost 2.3 degrees due to radiation. In that case, their formula was pretty accurate. But a man named Pouillet used the formula to estimate the temperature of the sun, got a value of some 1700 degrees, and that seemed pretty low to a certain Josef Stefan. He re-published the above data and proposed his famous fourth-power law on the relationship between heat-radiation and temperature on pages 391-428 of the "Sitzungsberichte der Kaiserlichen Akademie der Wissenschaften, Mathematisch-Naturwissenschaftliche Classe, Neunundsiebzigster Band, Wien, 1879".
95+
96+
;; ## The law of Stefan
97+
98+
(defn stefan-law [Celsius constants]
99+
(calcbox [((((chi plus xi) power 4 )
100+
minus
101+
(chi power 4))
102+
times
103+
omega)
104+
[with [xi in Celsius]]
105+
[and [[chi omega] being constants]]]))
106+
107+
^:kindly/hide-code
108+
(tex (:calc (stefan-law 'xi greek-alphabet)))
109+
110+
^:kindly/hide-code
111+
(kind/hiccup [:blockquote (:hiccup (stefan-law 0 greek-alphabet))])
112+
113+
;; We need to set omega-$\omega$ to one six billionth. The other constant is given by the absolute zero temperature, chi-$\chi$ = 273.
114+
115+
;; As an exposition, we calculate the fourth-power of 273.
116+
;; The result is a pretty big number.
117+
118+
^:kindly/hide-code
119+
(def pow_273_4 (calcbox [(((chi times chi) times chi) times chi) [with [chi equals 273]]]))
120+
121+
^:kindly/hide-code
122+
(kind/hiccup [:blockquote (:hiccup pow_273_4)])
123+
124+
^:kindly/hide-code
125+
(:calc pow_273_4)
126+
127+
;; I can imagine that in the 19th century, without having computers, to fit some data it took considerable guts to take on a fourth power law.
128+
129+
(defn stefan-law-numbers [Celsius]
130+
(calcbox [((((chi plus xi) power 4 )
131+
minus
132+
(chi power 4))
133+
times
134+
omega)
135+
[with [xi in Celsius]]
136+
[and [(one (6 billion) th) for omega]]
137+
[and [273 for chi]]]))
138+
139+
^:kindly/hide-code
140+
(kind/hiccup [:blockquote (:hiccup (stefan-law-numbers 0))])
141+
142+
^:kindly/hide-code
143+
(tex (:calc (stefan-law-numbers 'xi)))
144+
145+
;; Stefan's Law passes the first test in fitting the data as well as the old model.
146+
147+
^:kindly/hide-code
148+
(kind/table
149+
{"°C" temper
150+
"°C / min" dp-meas
151+
"D&P-formula" (map #(round (:calc (dp-formula %)) 2) temper)
152+
"Stefan law" (map #(round (:calc (stefan-law-numbers %)) 2) temper)})
153+
154+
;; With his new formula, Josef Stefan estimated the lower bound of the temperature of the sun to be around 5600 °C which means he was pretty much bang-on within some 100 degrees.
24.1 KB
Loading

0 commit comments

Comments
 (0)