[HN Gopher] Show HN: CalcuLaTeX, a pretty-printing calculator la... ___________________________________________________________________ Show HN: CalcuLaTeX, a pretty-printing calculator language Author : fish45 Score : 105 points Date : 2021-02-24 15:22 UTC (1 days ago) (HTM) web link (mkhan45.github.io) (TXT) w3m dump (mkhan45.github.io) | fish45 wrote: | Hey HN, I created CalcuLaTeX because I was frustrated with my | workflow for chemistry and physics homework. Generally, I'd use | the Python REPL as a calculator and type each problem into LaTeX | to turn it in. CalcuLaTeX merges these two steps and makes it | easier to reason about calculations by real time visual feedback. | | I've posted on r/rust as well (https://www.reddit.com/r/rust/comm | ents/lqn5aa/calculatex_a_p...), and there seems to be interest in | using it for scientific papers and such. | | The only alternative I know of is PTC MathCAD, which is quite | powerful and definitely worth looking into. However, it's quite | expensive and Windows only. | | The main repo (a Rust library and basic CLI) can be found here: | https://github.com/mkhan45/CalcuLaTeX | | The website repo using WASM and very hacky JS can be found here: | https://github.com/mkhan45/CalcuLaTeX-Web | FabHK wrote: | This is awesome! | | Is there a way to get the LaTeX source with the completed | calculation (so that you can copy/paste the whole thing in your | local LaTeX installation and, well, hand in your homework)? | (sort of a "middle" tab) | fish45 wrote: | The main export of the Rust/WASM library is just a function | which outputs LaTeX; it should be pretty doable to add a | button to the website which does what you're asking. I think | I'll just add a checkbox to set whether it actually renders | or not. | 8note wrote: | Ti-89 is a great option, since you can also get the nice | formatting while you're doing exams | RandomWorker wrote: | This is awesome! Does it do other conversions than weight? | mol/lengths/surface/volume/energy? | fish45 wrote: | It supports every SI unit and many derived units. It doesn't | yet support fractional units, e.g. km^3/2 though. AFAIK there | aren't any fractional units that have physical meaning but | they might appear in intermediate steps sometimes. | tobmlt wrote: | Imagine you are G.I.Taylor and its the start of The Cold | War. Life magazine has just published an amazing high speed | photographic sequence of the detonation of an atom bomb. | The nation is enthralled by these images, but you see a bit | further into the imagery. | | The pictures give you the radius of the blast as a function | of time. | | All that could be important In determining the radius R as | a function of time are the initial energy released, E, and | the density of the undisturbed medium, Rho. | | Thanks to your natural curiosity, you know the value of | dimensional analysis and reason that the radius, with | dimensions of length, must depend only on E, rho, and t, | for which the correct expression can only be: | | R(t) = (E/Rho t^2)^(1/5) | | Since E/Rho has dimensions of (length)^5/time^2 | | A log-log plot of r vs t (imagine measuring the radius of | the blast and carefully noting time stamps given in the | picture captions) gives a slope of 2/5, checking the | theory, and E/Rho could be obtained from extrapolation to | the value of log R when log t= 0. Rho is known For air and | thus E was determined to within a factor of order 1. | | For the practitioner of dimensional analysis, the nations | deepest secret had been published in Life magazine. | (Goldstein States of Matter, chapter 6) | | Ah, but how best to convey the findings? Surely the best | way is to use a mathcad like, But open source tool which | prints straight to latex! | | Ah ...if only it could express fractional units... | | GI Taylor prepares a letter to John wheeler, requesting a | closed time like networked computing device so that the | feature request can be made. | | In all seriousness though, This project is awesome! Just | kick in fractional unit support and it will surely be | unstoppable. | fish45 wrote: | Haha if only. | | GI Taylor should be able to publish his findings by the | end next week | tobmlt wrote: | Yeah they managed to find their way into circulation | somehow. ;) | | Not sure what I really had to add with that whole bit up | there. I suppose it's that sometimes intermediary units | are a fun part of the story! | | Anyway, very cool project. | FabHK wrote: | The unit of volatility is conceptually [time^{-1/2}], most | commonly 1/sqrt(year), but that is rarely written. (People | speak of a stock with 30% annual vol, not with a sigma = | 0.3 a^-0.5 :-) | fish45 wrote: | Weird units are cool. I was pretty mindblown when I | realized that radians are basically meters/meters and | steradians are meters^2/meters^2 | kccqzy wrote: | That's wonderful! When I used to do my math and physics | homework, I used Mathematica as a calculator. It has built-in | LaTeX formatting available (right click, Copy As > LaTeX). But | likewise Mathematica is expensive and proprietary software so | it doesn't appeal to everyone. | formerly_proven wrote: | FYI you might find the GNU units(1) tool useful, which has a | huge catalog of units and understands about the same set of | math operations as a scientific calculators. From the demo I | actually thought this was using GNU units in the background. | fish45 wrote: | That's pretty cool. I did search for a unit calculation | library before starting this but since WASM is a priority I | wanted to use a Rust one. | prezjordan wrote: | Very cool! The output looks nice, will definitely give this a | whirl for some blog posts. | fish45 wrote: | I'm glad to hear it! Feel free to open an issue if you'd like | anything added | hamaluik wrote: | I'm so glad you made this! I'm also very upset that this didn't | exist 10 years ago when I really needed it. Well done! | fish45 wrote: | Haha I don't think I understood the concept of units 10 years | ago | macintux wrote: | I used to do my calc and some CS homework in LaTeX. Seemed | easier than trying to write slowly enough to make my | handwriting legible. | SamBam wrote: | Very cool! | | What made you choose LaTeX for the tool? | | It seems like it wouldn't be too hard (maybe?) to get a proper | algebra engine to assign variables. Currently you can do `x = 10` | but you can't do `x / 2 = 5`. I feel like this would be very | helpful since you're using this for scientific calculations. | | It could then be possible to extend that further and leave the | variable undefined if it doesn't (yet) have enough information to | solve it. Then it could theoretically be used to solve | simultaneous equations. | fish45 wrote: | > What made you choose LaTeX for the tool? | | I was originally planning to use MathJax and HTML or Markdown | but honestly it wasn't a completely conscious decision. | | About proper algebraic stuff, it is a long term goal to have at | least a basic polynomial solver, but I've no experience in the | area and I'm not sure how far it can go. | Jakobeha wrote: | This is cool! I think it can be really useful. | | My main suggestion is better error handling: make it so that when | a calculation is invalid, it shows the error where the result | would be (e.g. red text with the error message) instead of | failing to compile the whole script. | fish45 wrote: | I definitely agree that error handling should be improved. I'm | trying to keep the LaTeX output as portable/minimal as possible | though so I'm not sure if highlights are doable. My current | plan is to output more diagnostic info and let the JS interface | figure it out. | drran wrote: | I use Marker markdown editor + MathJax + embedded JavaScript to | achieve similar results. | croddin wrote: | This is awesome. It reminds me of the iOS app Calca[1], which is | similar. | | [1] http://calca.io/ | nielsbot wrote: | I like Calca, and this looks like a cool project. Could be cool | to combine the 2 in an editor similar to Typora. | | Typora is my favorite Mac Markdown editor: It looks like a | plain word processor file, hiding the markdown annotations, but | they're still there and can be edited. I think it's ideal. | fish45 wrote: | That's really cool. I'll definitely look to it for inspiration ___________________________________________________________________ (page generated 2021-02-25 23:01 UTC)