Mathematica Jupyter Notebook

3 views
Skip to first unread message

Ozella Vires

unread,
Aug 4, 2024, 6:22:00 PM8/4/24
to tecycvapo
Iwant to buy a license for Mathematica and was checking the prices. Some people on Reddit have claimed that one can get a free a Wolfram Engine and install the Jupyter notebook interface and that is exactly Mathematica; so, one doesn't need to buy an independent Mathematica license. A blog post also claims as much.

The quality and usability of Jupyter with Mathematica is nowhere near that of the native notebook interface. While using Jupyter is much better than using the "naked" Mathematica kernel from the command line, and may be suitable for occasional use, it is not nearly comparable to using the full Mathematica notebook interface.


You may think that you would only want to type plain-text code, and you don't need 2D input. Similarly, you may think that you can live without creating Dynamic user interfaces. But these two features are so deeply integrated into Mathematica that the usability of the system suffers greatly if they are not available. Just a few examples of things you wouldn't be able to do:


In the past there were other limitations too, which may have been addressed since then, such as the lack of interruption support (which is very important for any sort of interactive work), the lack of auto-completion, or the lack of built-in documentation with immediately runnable examples.


To avoid misunderstandings, it's good to note that with the free Wolfram Engine you do get the full computational functionality. As far I know, there are no noteworthy limitations. Only the user interface will be lacking.


Everything that comes with the newest Wolfram kernel by just going on the cloud without the hassle of installing something on your computer. This can be nice to have even if your institution provides Mathematica as they might not update it right away.


When the command is followed by //TeXForm the Latex output is automatically rendered in Jupyter. This leads to beautiful output especially when compared to the default output which is rendered as a picture with a white background.


Possibly the biggest concern: As mentioned in Szabolc's answer, interrupting a cell leads to stopping the kernel and so one has to restart everything if a code cell takes too long. Use a=1;Pause[10];0then interrupt the kernel and then check that a is no longer defined.Maybe this could be partly solved using DumpSave (maybe Save is better) and $NewSymbol by saving all new symbols in a temporary file (maybe in $TemporaryDirectory) so that it is not saved forever (which could use a lot of memory on your hard drive). Other than using the DumpSave method, calling the wolfram kernel from python one could save some of the simpler variables in python like numbers and lists. For more complicated structures see this question or this question


No auto-completion or suggestions when writing system defined functions (although see Wolfram Engine + Jupyter $\stackrel?=$ Mathematica for what might be a fix but I did not test it and do not know if it autocompletes system functions)


"Undo" (Ctrl+Z) does not work well for me when I use jupyter notebooks with a python kernel. Perhaps that is also true with the wolfram kernel. In python this was less of a problem in JupyterLab and maybe that is also true for the vscode option below.


Using the $PrePrint method before, one can include an option to show the input form if the head is InputForm or a custom wrapper. However, in a large expression it might be irritating find the sub-expression desired when we are more familiar with the TeXForm.


Symbolic output like 5+x^2 and the output from Plot are written in FullForm. One can obtain images (for the expression and for the plot) using ExportByteArray and following the method in this page. Perhaps that can be shortened into a python function. The image outputs from that method look the same as when using directly the wolfram kernel in Jupyter (not calling wolfram kernel functions in python as is the case here). However, TeXForm does not work (it outputs the same FullForm with TexForm wrapped around un-evaluated).


The instructions are given in this page (probably auto-completion and documentation by hovering over functions will not be available as was the case for Jupyter notebooks on the browser, see the sentence below for a possible solution)


(Note : that last plugin did not work for me following the instructions on the Github page but it did work using a .ipynb jupyter notebook and selecting the wolfram language both as the kernel (at the time of writing top right in VScode) and as the interpreter (at the bottom right of a code/input cell, I think the name in this case is from the same plugin).


This might have happened after I initially wrote this but it seems that at least with the extension mentioned before, variables are kept when canceling a cell execution and so one might no longer need to restart the kernel.


Cons of Jupyter Notebook with the wolfram kernel minus autocompletion and the documentation. So no usage of Dynamic, no ToolTip, no 3D plot rotation, no image resizing by dragging (but on can set the image size manually with the ImageSize option), etc.


expression //TeXForm does not give nice LaTeX outputs with the current version of "Wolfram Language for Jupyter" on VScode. A work around was found on this page. Following the instructions in that answer, it suffices to rename the original RequestHandlers.wl file to something likeRequestHandlers_old.wl (for example) and then rename the RequestHandlers.wl.txt file in that answer to RequestHandlers.wl (maybe one should restart VScode after , maybe also the wolfram kernel, maybe also the computer, not sure).


I do not remember if Workbench needs the wolfram kernel or Mathematica. I also do not remember if the Mathematica plugin for IntelliJ IDEA can be used with only the wolfram kernel. I will only mention the option that I personally use which is the official wolfram plugin for VScode. The reasons why I prefer VScode rather than the native package handler or Workbench are that :


Hi,

Is there a way to convert Mathematica notebooks to jupyter notebooks and vice versa? If you are writing lecture notes using jupyter notebooks is a better option. However, in doing calculations Mathematica notebook is superior. If there is a simple conversion between two of them it would be very useful.


Converting a WL notebook to a Jupyter notebook and running the Jupyter server (with the free developer Wolfram Engine kernel) is currently the only way to truly share the WL notebook with people in the ML community without making them signup and learn Mathematica.


Unfortunately, this is not possible, you have to learn Mathematics because it is better in my opinion. Besides that for my writings I use -samples/lord-of-the-flies/ because there are funny topics like Lord of the flies here))This amuses me, especially because from here you can get a lot of information that will look pretty good for my project.


I'm going to second this question....I have some old Mathematica notebooks that I want to revisit using Jupyter Notebooks + Wolframe Engine. It would be helpful if I didn't have to rewrite the Mathematica notebooks.


Markdown language is easy to use for writing notes. Even though mathematical notebooks offer lots of features in the format of the text I guess it is behind the simplicity of the markdown language.Besides, more importantly, not everyone in our group has a license for Mathematica. Hence some of us are using the wolfram kernel via jupyter notebooks. It would be better if the conversion was possible.


This project is part of a follow-up effort to my Mathematica Class Demonstrations project. While I do still enjoy using Mathematica since it's so quick and easy (and I hate doing algebra by hand), unfortunately most people don't have access to it, which significantly limits the potential audience for my previously-uploaded demonstrations. Aside from (and even with) Wolfram Demonstrations there isn't really a good way to make Mathematica files available online, so in late 2020 I started to look around for some alternatives.


I came across a partial solution in the January 2021 issue of SIAM News, which included an article about a recently-published interactive textbook made in the form of a Jupyter Notebook. I had heard about and briefly looked into Jupyter Notebooks previously while teaching myself Python, but they seemed hard so I stopped. I also wasn't aware that they had the potential to make interactive widgets similar to Mathematica's Manipulate function, but after seeing what they could do I set out to try to learn how to remake some of my old Mathematica projects using Jupyter Notebooks.


This is still a work in progress. Jupyter Notebooks are a huge pain to develop as compared to Mathematica demonstrations, and I certainly don't expect to be able to port all of my old projects over, but I expect to be adding more over the years alongside some other web app formats.


Jupyter Notebooks are primarily meant for sharing code which can be executed by a server, which makes them great for computable notebooks, but I wanted to try to keep the output as simple as possible so that the user wouldn't have to think about or even look at the source code while looking at the interactive widgets. Normally a service like Binder would display the notebook as a sequence of executable cells, so in order to simplify the presentation all of the links below are run through Voil and rendered as standalone web apps.


In addition, unlike the original Mathematica projects I've made more of an effort here to work the interactive widgets into a full mini-lesson with all of the necessary explanatory text. Most of the projects below link to more than one notebook, including a full explanation as well as just the main interactive widget by itself.


This demonstration gives a brief introduction to cobwebbing, a graphical technique for quickly approximating the general behavior of a discrete dynamical system. This is a useful technique in mathematical biology since many population growth models take the form of a difference equation. In particular, if the population in the next time step is given as a function \(f\) of the population in the current time step, then the cobweb plot can be used to estimate the sequence of population values over many time steps by drawing a zig-zagging line alternately between the \(y = f(x)\) curve and the \(y = x\) line. The complete demonstration includes an explanation for the motivation behind cobweb diagrams and the reasoning behind why they work, and goes through a few population models as examples. The standalone version includes only a pair of interactive widgets showing the process of drawing cobweb plots for two systems with adjustable parameters.

3a8082e126
Reply all
Reply to author
Forward
0 new messages