latex-alpha2 icon indicating copy to clipboard operation
latex-alpha2 copied to clipboard

[Feature Request] Provide package option to run mathics

Open krishnakumarg1984 opened this issue 5 years ago • 12 comments

First of all, thank you for this package. So far, we didn't really have a seamless way to automatically typeset symbolic math code (sagetex was unsatisfactory).

I'd like to propose a solution that might lift the *nix restriction of the package - support the mathics executable as a package option. mathics is a free, open-source lightweight alternative to mathematica that entirely uses Wolfram syntax. Since you just have to add in a package option, this is likely to be a trivial change, but one that can immensely help those who cannot afford mathematica or are on windows. (mathics is fully cross-platform).

krishnakumarg1984 avatar Mar 05 '19 11:03 krishnakumarg1984

Hi @krishnakumarg1984 , thank you for your suggestion. First, I'd like to clarify that Mathematica and WolframScript do support Windows. The *nix restriction of the package is because several shell commands are used in the macros, but I'm not familiar with Windows commands, nor do I have a Windows computer near me at the moment to do tests.

Having said that, it would be nice to support Mathics nonetheless since it's syntax compatible with Mathematica and it would help those who do not have access to Mathematica. So I'll look into it.

stevenliuyi avatar Mar 05 '19 19:03 stevenliuyi

@stevenliuyi Thank you for your positive views on this suggestion. Here are a couple of clarifications.

  1. WolframScript is proprietary. I am a bit wary of running a script that I cannot inspect myself. This security aspect is one reason shell-escape is not enabled by default in many TeX distributions.
  2. mathics is essentially an independent implementation of the Wolfram Language i.e. the Wolfram Language specifications have been published as a standard. Mathematica is a proprietary implementation, while mathics is an independent open-source implementation that is free (in every sense, including the $$$ perspective). They are both drop-in replacements in my experience.

Maybe your package is not totally restricted to *nix envionments as you think? Could you please elaborate on the shell commands needed? If they are just the bash interpreter and the coreutils/binutils/findutils, they can be easily made available on Windows. For example, I always run my tex files from the excellent cmder application which provides a mostly unix-like environment natively on windows without any extra "installation" steps i.e. it is a portable application.

We can draw further inspiration by drawing parallels with your package to the iwolfram project. This is a jupyter kernel capable of running either mathematica or mathics.

Anyway, I don't have mathematica, but certainly do have mathics. If you can try to implememnt mathics support in a dev branch, I am happy to pull it and test it for you on Windows.

krishnakumarg1984 avatar Mar 05 '19 20:03 krishnakumarg1984

Thank you for the clarifications.

The main features only depend on rm and cp, which could be easily changed to Windows equivalents of course. Other commands used in the package include sed (for \wolframtex), convert (for \wolframanimation) and command (for checking availibity of wolframscript).

stevenliuyi avatar Mar 05 '19 21:03 stevenliuyi

Great. All of these are available on the portable cmder as well as the new WSL feature on Windows 10, and should work out of the box.

There are many, many native implementations of these tools via many ports. convert of course, is a part of imagemagick which is cross-platform.

This is looking more and more realistic to work on windows. Of course, I can't test it yet since I am not using mma.

krishnakumarg1984 avatar Mar 05 '19 22:03 krishnakumarg1984

Hi, I just added the support for Mathics.

stevenliuyi avatar Mar 06 '19 00:03 stevenliuyi

@stevenliuyi thank you. I have tested this. It didn't work on Windows, but worked decently on a linux machine.

  1. For the series expansion, I think this feature does not exist on mathics.
  2. The international dateline and the population examples invoke wolframalpha which will obviously will not work from mathics
  3. The Dsolve example works fine, but typesets Mathematica's output form. The output should be coerced into TeXForm. Therefore, can your package append the // TexForm string that is passed into mathics?
  4. Finally, the asymptote example for 3D plotting fails to compile.

krishnakumarg1984 avatar Mar 06 '19 19:03 krishnakumarg1984

Thank you for the test.

Actually the output of wolframdsolve is already in the TeXForm. It seems that Mathics' TeXForm function isn't ideal. For example, Sin[x] is converted to \text{Sin}\left[x\right] instead of \sin(x).

Besides, I tested myself and it seems the asymptote plot can be successfully compiled on Linux (see https://travis-ci.org/stevenliuyi/latex-alpha2). I'm not sure why it doesn't work on your machine.

stevenliuyi avatar Mar 07 '19 02:03 stevenliuyi

I forgot to mention that I raised an issue about the TeX conversion problem on mathics/Mathics#770.

stevenliuyi avatar Mar 10 '19 00:03 stevenliuyi

@stevenliuyi I just noticed that recently sagetex was updated to work with Python 3. What do you think about this?

krishnakumarg1984 avatar Mar 11 '19 15:03 krishnakumarg1984

@krishnakumarg1984 Sorry that I'm not familiar with SageTeX. FYI, I just found another package sympytex which is also kind of similar to SageTeX.

stevenliuyi avatar Mar 12 '19 20:03 stevenliuyi

@stevenliuyi great. But it seems to be not updated since 2014. I am inclined to now go with sagetex, considering the recent activity in that package maintainence

krishnakumarg1984 avatar Mar 12 '19 21:03 krishnakumarg1984

@stevenliuyi mathics achieved its 1.0 release a few months ago. And the new package author is going strong with tons of commits and frequent releases (I believe we are now up to 1.2 or so).

krishnakumarg1984 avatar Jul 10 '21 14:07 krishnakumarg1984