KatexCalc a configurable calculator and Katex formula-editor in Tiddywiki

It would be a good thing to have a KATE​X formula-editor (and helper!) that could at the same time be used as a calculator. This is a first attempt to integrate @Charlie_Veniot 's alculator with Katex.

He made a TW implementation of a calculator and macros that render the result

I made some slight changes: I put the evaluated formula into a temporary tiddler and I added a katex-line. And I made some more search replace filters to make the calculator render more katex expressions like the \pi and ^for powers.

I am also working on a Test to optimze the Design of the Calculator to be more suitable on smaller screens and to use the Linkcatcher to be more economical and easier to understand and to hack

<<calcrow "1 2 3 +" "99d">>
<<calcrow "4 5 6 -" "99d">>
<<calcrow "7 8 9 *" "99d">>
<<calcrow "0 . enter /" "99d">>
<<calcrow "Cos(x) 1/x (x) (x)^n" "9d9">>
<<calcrow "\pi Log(x) [<sqrt>] [[\frac 1 x]]" "d99">>

Results in:

Problems:

Some Katexexpressions can be rendered but for things with [ ] like $\sqrt[n]{(x)}$ (x)n\sqrt[n]{(x)}n(x)
because I could not find regex -filters to replace them by js eval expressions…

It would be great, if someone could implement a library to calculate directly with katex expressions like evaluatex

I turned it into a plugin not because it is ready but because this makes it more comfortable and reversible to play with it. It is allowed by Charlie (and me of course) to take this further.

KaTeX Calculator Experiment — a demo of the KaTeX plugin for TiddlyWiki5

1 Like

The calculator finally can render squareroots
screenshot-szen.io-2023.08.21-18_07_26

But it will be difficult to translate multiple nested expressions correctly
It is difficult to determine what wrapps what with a regex-filter - even if it is correctly displayed in the Katexline. We would need evaluatex for that.

screenshot-szen.io-2023.08.21-19_02_56

2 Likes

That’s very cool. Just done a few simple sums on my phone!