DEV Community

Cover image for The note keeps the final number, but not how it was calculated
Masaya Kumagai
Masaya Kumagai

Posted on

The note keeps the final number, but not how it was calculated

The note says "weighed 4.23 g". That number came from a calculator and was typed in. Some time later you want to make the same thing at twice the amount, and nowhere in the note does it say what was divided by what, so the calculation starts over from the beginning. Doing it in a spreadsheet would keep the formula, but then the formula lives in a different file from the note.

So Graphium has a Calculation block that does the arithmetic inside the note. Insert Calculation from the / menu and write one expression per line on the left. The results appear on the right. A value you name, as in target = 5 g, can be used by the lines after it. The note stores both the expressions and the values they produced. I think a record is better served when the way a number was reached stays readable right next to the number.

Units are carried through the arithmetic. Dividing 5 g by 233.19 g/mol gives an amount of substance, not a bare number, and it is shown with the prefix that reads best: 21.441743 mmol. Write to g and the result comes back converted to grams. A mix-up such as dividing where you meant to multiply is easier to notice from the unit of the answer, I think, so I chose not to drop the units.

A calculation block: expressions on the left, live results on the right

So that numbers do not have to be retyped into expressions, the block can also read the tables in the same note. sum(col("Weighing", "Mass")) reads a whole column of the table and adds it up. The total follows the rows recorded in the table, not a number copied by hand.

It also helps with data measured on separate instruments, where the measurement points do not line up. polyfit fits a polynomial to one of them, and polyval reads it again at the other one's points. A value read outside the fitted range carries a ⚠, so you can decide on the spot whether to use it.

A calculation block fitting thermal conductivity with a polynomial. The line read outside the range carries a warning marker

Variables live inside one block, so a name given in another Calculation block cannot be used directly. The tables a block can read are only those in the same note. Matrix products and inverses are not handled either.

How to write in a Calculation block is covered in the "Notes & editor" page of the manual. Calculating inside a note came in v0.35.0 (2026-08-13), reading tables in v0.50.0 (2026-09-01), and polynomial fitting in v0.72.0 (2026-09-11).

https://kumagallium.github.io/Graphium/manual/notes-and-editor#calculations

Graphium is open source on GitHub.

https://github.com/kumagallium/Graphium

Top comments (1)

Collapse
 
alexshev profile image
Alex Shev •

Keeping the final number without its derivation turns a result into an assertion that cannot be audited. I’d store the formula, source inputs, rounding rule, and calculation version beside the value, ideally as a generated artifact. Then a later correction can explain exactly what changed instead of merely replacing one number with another.