HNHacker News
TopNewBestAskShowJobs

cmferster

4 karma · joined July 5, 2020

submissionscomments
cmferster··on Handcalcs: Automatically render Latex equations from Python math code
But it doesn't do the calculation for you. handcalcs is about performing calculations and having it automatically show your work.
cmferster··on Handcalcs: Automatically render Latex equations from Python math code
Sympy is for solving an original solution. handcalcs is for plugging numbers into formulas. Next major milestone is integrating sympy with handcalcs so it is easy to transition from the sympy steps to the calculation steps.
cmferster··on Handcalcs: Automatically render Latex equations from Python math code
That is my hope! At least for more typical arithmetic.
cmferster··on Handcalcs: Automatically render Latex equations from Python math code
That's the current plan.
cmferster··on Handcalcs: Automatically render Latex equations from Python math code
Jupyter, and ultimately Python, evaluates the expressions. handcalcs just displays the resulting information with variable values from the Python locals dict.
cmferster··on Handcalcs: Write calculations in Python, rendered automatically as Latex
This is a library that I use daily in my work as a design engineer for quickly writing and printing calculations. My company has agreed that I may publish it as free and open source.

In the engineering world, often times Excel is king. However, it is not transparent: you type a formula in a cell and 1) the formula only contains cell references (unless you define cell names) and 2) the formula is hidden. For accountability, you have to separately type the formula in an adjacent cell so you can print your sheet out as a report or calc sheet. However, the formula you typed is just text: the resulting value has no relationship with the formatted formula you typed out and you have to change both to update. This makes maintenance cumbersome.

I wanted the formula I typed to be the same as the formatted representation of the formula I typed -- change the representation and the result changes. SMathStudio and MathCAD do this but you still have to layout formulas on the sheet and, most importantly, none of these software packages show the numerical substitution, critical for quickly checking correctness of calculations. I wrote handcalcs to address this problem.

To use: run Jupyter and use the cell magic, %%render, then just type in your calculations. Run the cell to see them all rendered out in Mathjax or Katex.

While it is designed to work in Jupyter, it also has a decorator interface for use in other environments that render Latex (e.g. Streamlit).

The intended audience for handcalcs is engineers, estimators, teachers, students, or anyone else that tends to need to perform documented calculations. However, I am guessing that this may be useful to many others in ways I do not know.

Open to feedback and suggestions for enhancement!