by knight17 · 6y ago · 0 comments
I use the Emacs calculator (M-x calc) and XCalc (http://www.tordivel.no/xcalc/) as I like to use RPN calculators. The Windows 10 calculator is painful and slow. XCalc has a mini mode, where it will sit as a small, single line without distracting you too much. I like that feature very much.
One thing with Emacs is that I forget the shortcuts for non-frequent calculations that I'd have to go and search for it.
$ alias units='units --verbose' # in your shell rc
$ units
Currency exchange rates from FloatRates (USD base) on 2019-06-05
3460 units, 109 prefixes, 109 nonlinear units
You have: 56 kibibit/second
You want: hour/20 mebibyte
reciprocal conversion
1 / (56 kibibit/second) = 0.8126984126984126977077949 hour/20 mebibyte
1 / (56 kibibit/second) = (1 / 1.23046875) hour/20 mebibyte
Note that if you are on macOS, you want to install a more recent units via homebrew. The one shipping with the base system is positively ancient.During grad school, I went through a period of trying many different GUI based calculators, until I realized what I really wanted was a language's repl.
See Andrew Hyatt's Emacs calculator for Financial calculation tutorial: http://web.archive.org/web/20171218022230/https://plus.googl...
(Link rot, Google Plus, web.archive.org!)
The other thing I do frequently is fire up a python3 repl for quick hits. I just did it yesterday for a complex mass file rename I couldn’t figure out how to do with shell variable replacement. With python it was easy with glob and os.rename.
$ ev() { echo "scale=3; $*" | bc -l; }
$ ev 22/7
3.142$ math() { echo "scale=2 ; $" | sed -e "s:x::g" | sed -e "s:,::g" | bc; }
$ math 5,382 x 48,927.3
263326728.6
$ math() { echo "scale=2 ; $*" | sed -e "s:x:*:g" | sed -e "s:,::g" | bc; }
$ math 5,382 x 48,927.3
263326728.6The one downside is you can't do unit conversions of a mathematical expression, just of a number. (i.e., 2^2 m/s does not work but 4 m/s does).
Whenever I have to do something more complicated I usually use M-x calc or maxima with ezunits.
The non-RPN one that I use the most is SpeedCrunch (http://speedcrunch.org/), Insect (https://github.com/sharkdp/insect/) and Frink (http://frinklang.org/). All have unit conversion too.
Other than that, I use scratch in elisp mode and eval. Not as fluent as magnars, but this is a good example of what I mean (towards the end): https://youtu.be/jNa3axo40qM
Qalculate takes unit-aware calculation to the next level by including an algebraic solver. You don't have to rearrange everything to put your unknown on one side - you can just chuck 'x' into your equality somewhere and it'll work it out. For example, to verify the what-if xkcd assertion that an A10's main gun will propel Randall's car up to 7mph in 3 seconds:
(60/s) × (x s) × (395 grams) × (1010 m/s) = (3500 lbs)(70 mph) ≈ x = 2.0754319 s
2 seconds! Maybe Randall's car is heavier than 3500 lbs. How much heavier?
(60/s) × (3 s) × (395 grams) × (1010 m/s) = (x lb)(70 mph) ≈ x = 5059.1879
More like a Dodge Durango. Unless he's accounting for friction.
You see how nice it is to be able to swap around the unknowns in an equality. Other great features are a large number of built-in constants, an astounding variety of built-in functions - it's practically a CAS - and a command history, which is where I pulled the above example from. It also has a plugin for Plasma's krunner, so you can do quick calculations right there in the dropdown. To summarize: Qalculate is the shit.
Otherwise I use WolframAlpha a lot.