labcalc 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ dist/
labcalc-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 the labcalc authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
labcalc-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,387 @@
1
+ Metadata-Version: 2.5
2
+ Name: labcalc
3
+ Version: 0.1.0
4
+ Summary: A terminal calculator for lab work and physics homework: uncertainties, units, complex numbers, solving
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Keywords: calculator,error propagation,lab,physics,uncertainty,units
8
+ Classifier: Environment :: Console
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Physics
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: prompt-toolkit>=3.0.40
16
+ Description-Content-Type: text/markdown
17
+
18
+ # labcalc
19
+
20
+ A terminal calculator for lab work and physics homework. It carries
21
+ uncertainties through the maths for you, and handles units, physical constants,
22
+ complex numbers, fractions, your own functions and solving equations. The
23
+ result of a line shows next to it as you type; Enter commits it.
24
+
25
+ ```
26
+ > L = 1.203±0.001
27
+ 1.2030 ± 0.0010 (0.083%)
28
+ > T = 2.201±0.005
29
+ 2.2010 ± 0.0050 (0.23%)
30
+ > g = 4pi^2 L/T^2
31
+ 9.804 ± 0.045 (0.46%)
32
+ > why g
33
+ T 97%
34
+ L 3.2%
35
+ > g vs 9.81
36
+ differ by -0.006 ± 0.045 (-0.065%, 0.14σ, p = 0.89)
37
+ ```
38
+
39
+ ## Install
40
+
41
+ ```sh
42
+ pipx install labcalc # or: uv tool install labcalc
43
+ labcalc # start it
44
+ labcalc web # the same calculator in a browser tab
45
+ ```
46
+
47
+ From a copy of this repository: `uv run labcalc`, or
48
+ `uv tool install --editable .` to get `labcalc` everywhere.
49
+
50
+ `labcalc web` writes `labcalc.html` (next to the saved state, in
51
+ `~/.local/state/labcalc/`) and opens it. The page runs this same Python code
52
+ in the browser with [Pyodide](https://pyodide.org), loaded from
53
+ cdn.jsdelivr.net the first time (so it needs the internet then; afterwards the
54
+ browser usually has it cached). It works as the terminal does: colours,
55
+ preview, Tab, ↑ with a typed start, `+-` to ±, Ctrl-C or Esc to clear the
56
+ line, Ctrl-L to clear the screen. It starts with the terminal's equipment
57
+ errors, then keeps its own in the browser's storage, with its sessions: `load`
58
+ brings back the tab's last session, and `save hw3` keeps one there and offers
59
+ it as a file to download.
60
+ Bookmark the file; run `labcalc web` again after updating to rebuild it.
61
+
62
+ ## Syntax
63
+
64
+ | Type | What it does |
65
+ |---|---|
66
+ | `x = 5` | Set `x`. Prints the new value, with `(was 3)` if `x` existed. A value with a prefix shows plain SI too: `50 nF = 5E-8 F`, `-31.06 km = -3.106E4 m` |
67
+ | `x = 5+-0.1`, `x = 5+-2%` | With an uncertainty (`+-` and `+/-` become `±`) |
68
+ | `x = 5 ± 0.5% ± 2/sqrt12` | Several independent uncertainties, e.g. meter spec plus resolution |
69
+ | `x = 3.47 ±` | Resolution: one unit of the last digit typed, over √12 (here 0.01/√12). Same as `± res` |
70
+ | `x = 3.47 ± 2d` | Two units of the last digit typed, for this reading (a meter's "+ 2 digits") |
71
+ | `err_dmm = ± 0.5% + 2d` | Save an equipment error: % of the reading, a fixed amount (`0.5 mm`), and/or `d` digits of the last digit typed, added as a meter's spec means. Any one alone is fine. Kept between sessions; `list` shows them |
72
+ | `x = 5 ± err_dmm ±` | Use it, here with the reading's resolution as well. `± dmm` will do |
73
+ | `x = 500 mV ± 4` | A unit after a space, or straight after the number (`500mV`, `4.7kohm`, `12V`) unless there's a variable of that name (then `2m` is 2 times m). Units are carried through: `R C` with `1.8 kΩ` and `100 nF` is `180 µs` |
74
+ | `t = 20, 48, 80 ± 1` | A list: `t_1`, `t_2`, `t_3`. A ± or unit on the last value applies to all. Names like `r_c`, `r_l` are names of their own too: `r = 100` sets `r` beside them (it only types over a list with numbered entries) |
75
+ | `n = 0..9`, `c = a, b` | A list counting up; two lists joined into one |
76
+ | `x =` | Set `x` to the last value printed (Tab after `=` types in what that is, to edit) |
77
+ | `ans` | The last value printed: `ans * 2`. Something made with it keeps its value, as with `:=`, since `ans` is something else after every line |
78
+ | `ans = 2` | Solves the expression just before it: after `1/sqrt(1 - v^2/c^2)` (an error, `v` unknown) it runs `1/sqrt(1 - v^2/c^2) = 2`. If everything in it was known, it solves for its one variable; with several, add `solve a` |
79
+ | `g = 4pi^2 L/T^2` | Follows its inputs: change `L` and `g` updates, and so does anything made from `g` |
80
+ | `k := 2L` | Fixed: keeps its value when `L` changes |
81
+ | `x` | Print `x` and how it was made (`:=` if it's fixed) |
82
+ | `x.3` | Print `x` to 3 significant figures |
83
+ | `x.mm`, `x.us`, `x.deg`, `(W - w).um` | Print `x` (or a bracketed expression) in a unit; an error if it isn't in that kind of unit |
84
+ | `x.3 mm` | Both: 3 significant figures, in mm |
85
+ | `unit x` | `x` in SI base units: `1800 ± 18 m² kg s⁻³ A⁻² (1.0%)` for 1.8 kΩ |
86
+ | `g = 4pi^2 L/T^2` | With exactly one undefined name, solves for it and prints which |
87
+ | `abs H = 1/sqrt2 solve w` | Solve for the names after `solve`, even ones already set. Anything made from them (H from w) is worked out again at each try. Solved through what it changes like this, the answer keeps its value afterwards (`kept as fixed`) |
88
+ | `a + b = 3, a = 2b` | Several equations, as many unknowns: solved together. `… solve a b` to name them |
89
+ | `f(x) = x^2 + a` | A function of your own: `f(3)`, `2f(t)`, a list (`f(t)` with t a list), several values (`g(x, y) = …`). Other names in it are the variables, followed as they change, and so is anything made with `f` when `f` is changed. `f` prints it; `del f` removes it |
90
+ | `R1 \|\| R2` | In parallel, R1 R2/(R1 + R2); binds tighter than `+`, looser than `*`. `\|z\|` is `abs z` |
91
+ | `why g` | Each measurement's share of `g`'s uncertainty |
92
+ | `a vs b` | The difference, as a % of b, how many σ apart, and p. Two lists: entry by entry |
93
+ | `fit y x` | Straight line through two lists: `slope`, `intercept` and χ²/dof |
94
+ | `fit y x origin`, `fit y x unweighted` | Through the origin; every point counting equally, error from the scatter. `o` and `u` will do |
95
+ | `fit y x 2` | A quadratic, y = `quad` x² + `slope` x + `intercept` (`slope` is the gradient at x = 0). Takes `o` and `u` too |
96
+ | `mean t`, `wmean t`, `sum t`, `std t`, `max t`, `min t` | Of a list; `mean(r1, r2, r3)` takes each entry's mean across lists |
97
+ | `diff t` | Differences of neighbours: `t_2 - t_1`, `t_3 - t_2`, … |
98
+ | `table t V` | Lists side by side |
99
+ | `del x`, `reset` | Remove `x` (or a whole list, or a function), or everything |
100
+ | `clear` | Start again, on a clear screen: no variables, functions or `ans`, radians; only the equipment errors stay. `undo` brings back what was there, or later `load` (it becomes the last session). Ctrl-L only clears the screen |
101
+ | `save hw3`, `load hw3` | Save the session as `~/Documents/labcalc/hw3.labcalc`, and load it back (replacing this one; `undo` undoes the load). The file is each line with what it printed as a `#` comment under it, so it prints as a record and loads as it ran |
102
+ | `load` | The last session again, e.g. after a crash or closing by mistake, then anything typed since. Like `load hw3`, it shows each line it ran and what it printed, and ↑ reaches them. Each session saves itself as it goes, once it changes something; only the one before is kept |
103
+ | `list` | Every variable, function and equipment error |
104
+ | `undo`, `redo`, `undo 3` | The last line that changed anything (or the last 3), including what it updated. A line that worked something out changed `ans`, and `deg`/`rad` the angle mode, so those undo too (`ans = 1E4 (was 2E4)`); they don't lose what there is to redo |
105
+ | `30°`, `30 deg`, `25°30′`, `25 deg 30'` | An angle in degrees; it prints in degrees |
106
+ | `deg`, `rad` | Degree mode (the prompt is `deg>`) or radian mode (`>`, the default) |
107
+ | `help` | Short reference |
108
+ | `exit`, `quit` | Close |
109
+
110
+ ### Spaces group
111
+
112
+ What's written together belongs together:
113
+
114
+ - No space binds tightest: `2pi`, `1/2pi` = 1/(2π), `6/2(1+2)` = 1.
115
+ - A space multiplies at ordinary precedence: `1/2 M a^2` = ½Ma², `1/2 pi` = π/2,
116
+ `m 1E-3` = m × 10⁻³. Two numbers with only a space between them (`2 3`) is an
117
+ error, since it's usually a typo.
118
+ - ± joins the word before it to the word after it: `175 ± 1 + 273.15` =
119
+ (175 ± 1) + 273.15 and `20 ± 0.2 / 2` = (20 ± 0.2)/2, but `5 ± 0.2/2` =
120
+ 5 ± 0.1 and `3.47 ± 0.01/sqrt12` keeps the whole error together.
121
+ - A function without a bracket straight after it takes the next word, up to
122
+ the next space: `ln 8/7` = ln(8/7), `ln 8 /7` = ln(8)/7, `sin 2x` = sin(2x),
123
+ `sin x cos x` = sin(x)·cos(x), `ln2` = ln(2). With a bracket straight after,
124
+ just the bracket: `sin(x)^2` = (sin x)².
125
+ - After a number, a space and a unit gives it that unit: `500 mV`, `1.8 kohm`,
126
+ `9.81 m/s^2`, `5 cm²`. A unit applies to the whole word before it if that's
127
+ all numbers: `1/1200 mm` = (1/1200) mm, but `R/10 Mohm` = R/(10 MΩ).
128
+ Without the space it multiplies: `2m` = 2·m, and `1.8k` is an error that
129
+ says so. After an exponent it's a name: `4pi^2 C` uses your `C`. `600 /mm`
130
+ is per mm.
131
+ - A unit that is also one of your variables is the unit in a measurement
132
+ (`M = 120.3 ± 0.1 g` is grams even with `g` defined, `0.5 m/s` is m/s even
133
+ with `m` and `s`) and an error next to other variables (`1/2 m v^2`); write
134
+ `*m` to multiply. Names read as units are green.
135
+
136
+ ### Other notation
137
+
138
+ - `^` takes a single value: `2^3x` = (2³)x. Write `V^(-1/2)` for a fractional power.
139
+ - `E` after a number or `)` is a power of ten: `1.6E-19`, `(1.05 ± 0.01)E-3`.
140
+ Results from 10⁴ up or below 0.001 print this way (`1.732E4`), and can be
141
+ pasted straight back in, `(0.46%)` and all.
142
+ `e` on its own is Euler's number.
143
+ - Angles are kept in radians underneath, so switching mode never changes a
144
+ value. An angle typed in degrees (`30°`) prints in degrees, and its ± is in
145
+ degrees too: `12.0° ± 0.1`. In degree mode (`deg`, prompt `deg>`), sin, cos
146
+ and tan read a plain number in degrees (`sin 30` = 0.5) and asin, acos,
147
+ atan and atan2 give angles that print in degrees; in radian mode (`rad`,
148
+ prompt `>`) they read and give radians. An angle is an angle in either mode:
149
+ `sin 30°` is 0.5 in both. `x.deg` and `x.rad` print in either.
150
+ - `sin^2 x` = (sin x)², `sin^-1 x` = `asin x` = `arcsin x`.
151
+ - Pasted symbols work: `− × · ÷ ** π √ ² ³ ⁻¹ µ Ω`. `#` starts a comment.
152
+ - Greek letters by name: `alpha`, `theta`, `mu0`, `omega_1` become `α θ μ0 ω_1`
153
+ as the word ends (and `hbar`, `eps` become `ħ ε`). Not `pi`, or `Omega`, since
154
+ `Ω` is the ohm.
155
+ - Functions: `sin cos tan sec csc cot` and inverses, `atan2(y, x)`, `sinh cosh
156
+ tanh` and inverses, `ln log exp sqrt cbrt abs`, `arg re im conj`, plus `mean wmean sum std max
157
+ min diff` over lists.
158
+ - An exact result whose decimal never ends prints as a fraction too:
159
+ `1/7 + 1/11` gives `18/77 ≈ 0.2337662338`, `(1 + 2i)/3` gives `1/3 + 2i/3 ≈
160
+ …`, if the bottom is 100 or less and it's under 10⁴. `x.3` prints just the
161
+ decimal.
162
+ - Complex numbers: `i` is √−1, so `3 + 4i`, `R + i w L`, `e^(i pi)` = -1.
163
+ So is `j` (`R + j w L`, `4j`), unless you have a variable `j`; while something
164
+ uses `j` as √−1, `j = …` is refused rather than change what that means.
165
+ `4i` is one number (`1/4i` = 1/(4i), `2i kΩ`). `abs arg re im conj` take one
166
+ apart; `arg` follows deg/rad mode. `sqrt(-4)` = 2i, and `ln`, `asin` etc.
167
+ go complex outside their real range. Results print as `(3.0 ± 0.1) + (4.0 ±
168
+ 0.2)i (5.00 ± 0.17 ∠ 53.1 ± 1.7°)`, each part with its own ±, then the size
169
+ and angle (in degrees or radians by the mode); a ± goes on each part as you type it
170
+ (`(3 ± 0.1) + (4 ± 0.1)i`). Every source keeps its own complex contribution,
171
+ so `abs H` and `arg H` of a filter's response get the right error, with the
172
+ real and imaginary parts' correlation included. Fits, `vs`, mean and the
173
+ other list statistics (bar `sum`), and solving need real numbers.
174
+ - Units: `m g s A K mol V ohm Ω F H Hz T Wb S N J W Pa C eV Å` with prefixes
175
+ `p n u µ m c k M G`. `100 nf` says it means `nF`.
176
+ - Constants (SI, with units): `c h ħ G qe me mp mn kB NA ε0 μ0`. A variable,
177
+ list or function of your own with the same name takes their place. An
178
+ equation with nothing else unknown doesn't solve for one (`9.81 = 2h/t^2`
179
+ says so); add `solve h` for your own h.
180
+ - Tab completes names. Ctrl-C clears the line, Ctrl-D quits. ↑ goes back
181
+ through what each line worked out, as text to edit (`1E4 s⁻¹`), then the
182
+ line itself: value, line, value, line. A value shows the line it came from
183
+ beside it (`1E4 s⁻¹ ← w = 1/(R C)`). Type a start first (`La` then ↑) to
184
+ go straight to a line.
185
+
186
+ ### Seeing how a line was read
187
+
188
+ After Enter, the line stays on screen with brackets put in wherever the
189
+ spacing rules read it in a way that could be taken for something else, so a
190
+ slip shows straight away:
191
+
192
+ ```
193
+ > f = 1/2pi C (R+4.5) # typed
194
+ > f = (1/(2pi)) * C (R+4.5) # shown: C (R+4.5) is on top, not under 2π
195
+ > sqrt3/2
196
+ > sqrt(3/2) # not √3 / 2
197
+ > 175 ± 1 + 273.15
198
+ > (175 ± 1) + 273.15
199
+ ```
200
+
201
+ Only brackets (and a `*` where a bracket would turn a variable into a unit)
202
+ are added; the line means exactly what it did, and ↑ brings it back that way.
203
+ Lines with nothing to mistake (`4pi^2 L/T^2`, `mean t`) stay as typed.
204
+
205
+ ### Units
206
+
207
+ Units are optional. Everything is worked out in SI base units (m, kg, s, A,
208
+ K, mol) and shown the simplest way, with a prefix that puts the number (or its
209
+ ± if bigger) between 1 and 1000. A value typed in a unit prints in it
210
+ (`120.3 cm` stays in cm, `133.0 Hz` keeps its `.0`) if that's as simple as the
211
+ SI way: `30 mm/s`, `13 kV/m`, `4180 J/(kg K)` and `2 N m` stay, but `5 V/A`
212
+ prints as `5 Ω`, `2 A s` as `2 C`, `2 m/ms` as `2 km/s`, `13 kV/cm` as
213
+ `1.3 MV/m`. Mass in a compound unit is in kg (`3 g/cm^3` is `3000 kg/m³`):
214
+
215
+ ```
216
+ > R = 1.8 kohm ± 1%
217
+ > C = 100 nF ± 1%
218
+ > R C
219
+ 180.0 ± 2.5 µs (1.4%)
220
+ > g = 4pi^2 L/T^2 # L in cm, T in s
221
+ 9.804 ± 0.045 m/s² (0.46%)
222
+ > g.cm/s^2
223
+ 980.4 ± 4.5 cm/s² (0.46%)
224
+ ```
225
+
226
+ - A number without a unit, added to or compared with a value you typed in a
227
+ unit, is in that unit: with L typed in mm, `L + 1` adds 1 mm; with T in K,
228
+ `T + 273.15` adds 273.15 K; `0.840 ± bw/2` with bw in Hz is in Hz. So is a
229
+ saved error with no unit (`err_eye = ± 0.5`) on a reading in mm, and one entry
230
+ of a list typed in a unit (`t_3 = 32.4`).
231
+ - Next to a worked-out value, whose unit was never typed (`L/T`), a sum can't
232
+ tell which unit a plain number is in, so it says so. `vs` reads it in SI,
233
+ so `g vs 9.81` works. `0` goes with anything.
234
+ - A list can't have some entries in mm and some without a unit, and
235
+ `152 -+ 1 mm` asks `did you mean ±?`.
236
+ - Two different units can't be added or compared (`can't add m and s`).
237
+ Forget a unit in a product and the result's unit shows it.
238
+ - Values you typed in Hz stay in Hz, and so do their sums; anything else per
239
+ second is s⁻¹ (so 2π f isn't shown in Hz). Once you've typed `eV`,
240
+ energies print in eV, where the number fits (12 J stays J). A torque typed
241
+ in `N m` stays in N m; an energy worked out is J.
242
+ - A solved unknown gets the unit that makes the equation's units agree.
243
+ - sin, exp and the like give plain numbers, and need one (ln and log take
244
+ anything, for plotting ln V). A power can't have a unit.
245
+
246
+ ### Lists
247
+
248
+ A formula that uses a list works entry by entry, and a plain variable used
249
+ alongside is shared by every entry:
250
+
251
+ ```
252
+ > V1 = 2, 4, 8 ± 0.1
253
+ > V2 = 1, 1, 1
254
+ > T = (V2/V1)^2
255
+ [1: 0.250 ± 0.025 (10%)]
256
+ [2: 0.0625 ± 0.0031 (5.0%)]
257
+ [3: 0.01563 ± 0.00039 (2.5%)]
258
+ ```
259
+
260
+ Solving works entry by entry too. `± res` in a list uses each value's own
261
+ last digit: `t = 20, 4.8, 0.85 ±`. If entries have ± of their own, the last
262
+ one's is its own too; for one more ± on all of them, bracket the list:
263
+ `(6.0 ± 0.2, 24.0 ± 0.5) mV ± err_ch2`. `mean t` gives the mean ± its standard
264
+ error from the scatter. `wmean t` weights each value by its own errors, with
265
+ χ² per degree of freedom (about 1 if the values agree) and any value more than
266
+ 3σ from the weighted mean of the others.
267
+
268
+ While you type a list, the preview counts its entries (`7 entries`), so a
269
+ missed reading shows before Enter. Typing over a list says so (`replaced t (8
270
+ entries)`); so does typing a single value over a list.
271
+
272
+ ## How uncertainties combine
273
+
274
+ Standard first-order propagation: each `±` you write is an independent source,
275
+ and a result's uncertainty is the quadrature sum of (∂f/∂source)·σ over the
276
+ sources it depends on. A variable used twice is therefore correlated with
277
+ itself (`x - x` is exactly `0`, and `x*x` matches `x^2`), and so is anything
278
+ computed from it. `why` lists these per-source contributions.
279
+
280
+ - `mean` keeps errors common to the readings (a calibration) as they
281
+ are, since averaging doesn't reduce them. Each reading's own errors are
282
+ replaced by the standard error of the scatter, or kept if the scatter is
283
+ smaller than they claim.
284
+ - `wmean` weights each value by 1/σ² of its own errors: all but those common
285
+ to them, in more than half of them (a reading of 0 has no gain error, but
286
+ the gain is still common). Those (a calibration) don't set the weights,
287
+ where they'd pull the mean below every value; they're carried into the
288
+ result in full. An error only a couple share (the reading two differences
289
+ have in common) counts as each one's own, and its correlation is carried
290
+ through.
291
+ - `vs` gives p, the chance of a difference at least this big if the two were
292
+ really equal (Gaussian errors). It is not the chance that they are equal.
293
+ - `fit` weights each point by 1/σ² of its own errors (σy² + (gradient·σx)², or
294
+ the variance of y − gradient·x when x and y share an error), and carries all
295
+ the points' uncertainties (common ones included, which widen the result
296
+ without moving it) into `slope` and `intercept`, which stay correlated.
297
+ Without uncertainties on the points, the error comes from the scatter about
298
+ the line. Its error is not scaled by √(χ²/dof), as some fitting programs'
299
+ are: a χ²/dof well above 1 says the errors are too small, so check it.
300
+ - A new `fit` doesn't take over what was made from the last one's `slope`:
301
+ that stays with its own fit, which still refits when its data change (it
302
+ says which: `still from fit b a: K`).
303
+ - "nonlinear: ± is rough" appears when a function's slope changes a lot
304
+ across a value's ± range, or the range reaches a division by zero, so
305
+ first-order propagation isn't reliable there, e.g. `ln(0.1 ± 0.08)`.
306
+
307
+ Each session saves itself to `~/.local/state/labcalc/session.labcalc` as it goes, so
308
+ the next one can `load` it (a session spent only looking doesn't replace the
309
+ one before). Equipment errors are kept there too, in
310
+ `errors.json`, and load at every start. Their names start with `err_`, so
311
+ they can't be mistaken for variables; after ±, `dmm` is short for `err_dmm`,
312
+ so while `err_dmm` is saved there can't be a variable `dmm` (nor the other way
313
+ round). A name that's also a unit (`err_mm`) has no short form: `± mm` stays
314
+ the resolution in mm. `del err_dmm` removes one, and `reset` leaves them.
315
+
316
+ ### Equipment errors are shared
317
+
318
+ A saved equipment error is the instrument's calibration error (a scope's ±3%
319
+ gain, a meter's ±(0.5% + 2 digits)): the same for every reading taken with it.
320
+ So all readings that use `err_scope` share one source of uncertainty. Its % is
321
+ a gain, so it keeps the reading's sign: it cancels in `a/b` and `a+b` for −10
322
+ and +10. Its digits part is each reading's own. As on a meter's data sheet,
323
+ the parts add: a reading of 4.00 V on 0.5% + 2d is ± (0.02 + 0.02) V. The %
324
+ part stays shared, so it still cancels in a ratio of two readings, and the
325
+ reading's own part is what makes up the rest of the sum (√(0.04² − 0.02²) V
326
+ here). The shared part partly cancels in a difference, and doesn't shrink when
327
+ you average. Reading errors, which differ from reading to reading,
328
+ go on each value: a bare `±` (resolution) or a typed amount.
329
+
330
+ ```
331
+ > err_scope = ± 3%
332
+ > V1 = 2.00 ± scope ±
333
+ > V2 = 1.00 ± scope ±
334
+ > V2/V1
335
+ 0.5000 ± 0.0016 (0.32%) # only the reading errors are left
336
+ ```
337
+
338
+ One setting stands for one instrument on one setting: save `err_ch1` and
339
+ `err_ch2` if two channels or ranges have separate calibrations. Specs are used
340
+ exactly as given.
341
+
342
+ ### Following inputs
343
+
344
+ Anything set with `=` from other values follows them: change `L` and `g`
345
+ updates, then anything made from `g`, in order. Solved values re-solve,
346
+ fits refit, and readings follow a changed equipment error. The change prints
347
+ each update (`g = 10.594 (was 9.804)`), and a refit's χ²/dof, and `undo` reverts all
348
+ of it at once. If an update can't be done (a division by zero further down),
349
+ the change is refused. Fixed values the change would otherwise have updated
350
+ are listed (`kept as fixed: k`).
351
+
352
+ A list formula keeps up with its lists: if `V` gets another entry, so does
353
+ `P = V^2`. A list entry you set on its own (`x_2 = 2.50 ± err_cal`, correcting a
354
+ reading) stays as you set it.
355
+
356
+ A name like `th_s` would be an entry of the list `th`; if something is made
357
+ from `th`, that's refused (`call it something else`) rather than quietly
358
+ changing it. Its next entry (`th_6` after `th_5`) is fine.
359
+
360
+ Deleting entries (`del y_4`) updates what uses the list: a fit refits on the
361
+ rest, `P = V^2` loses that entry too. Anything that can't be updated yet (a fit
362
+ whose lists now differ in length) keeps its value and says `not updated`; it
363
+ catches up once it can (`del x_4` too). The same goes for what used something
364
+ deleted by name.
365
+
366
+ Set with `:=` instead, a value stays as it is: `k := 2L`, or `k :=` for the
367
+ last result. `x = 2x` (anything that uses itself) also just stores the value.
368
+
369
+ ### Catching slips
370
+
371
+ - Names are coloured as you type: cyan for yours, red for unknown ones. In a
372
+ line with `=`, a new name being set is cyan, the one name it would solve for
373
+ is underlined (so `g = 4pi^2 L/T2^2` shows it's solving for `T2`), and two or
374
+ more unknowns are red.
375
+ - The grey preview shows what Enter would do; a mistake usually shows there
376
+ first. `reset` previews as `clears 12 variables`.
377
+ - `undo` reverts a change and everything it updated; a long list of changes
378
+ (undoing `reset`) is cut short.
379
+
380
+ Uncertainties print to 2 significant figures, values to the same decimal place.
381
+ Full precision is kept internally.
382
+
383
+ ## Tests
384
+
385
+ ```sh
386
+ uv run pytest
387
+ ```