If you're using it, what are you using it for exactly? In what way is it irreplaceable by other tools out there, if at all?
If you're using it, what are you using it for exactly? In what way is it irreplaceable by other tools out there, if at all?
I started using Mathematica in middle school and continued from there. My initial use case was simply double-checking I did my math homework correctly. A lot of Solve, DSolve, FindInstance, Reduce, FullSimplify, etc. I did a lot of plotting to visualize things: not just plotting functions of one variable, but parametric curves, inequalities, functions of multiple variables. When I studied linear algebra, I implemented Gaussian elimination myself as a learning exercise and I was very proud of it: the nice thing was that although the algorithm worked on matrices containing known numbers, it automatically worked for matrices containing unknowns thanks to its symbolic computation. When I studied basic image processing tasks like edge detection or the like, it was again of great help. When I got into personal investing, I did yet more calculations using the FinancialData function to retrieve financial time series and backtested many kinds of portfolio. When I got into trading options, it was of tremendous help to learn options from first principles, starting from the log-normal distributions, implementing Black–Scholes modeling, and then implemented the option greeks (delta, gamma, theta, etc) from scratch. Even as a regular software engineer, when I needed to work on algorithms, Mathematica is great help when I needed to do complexities analysis more sophisticated than interview-level big-O notations. I even used it as a SAT solver in a pinch, or a linear programming solver, when I knew there are other tools, but they won't be as nice as Mathematica or have higher learning curves than Mathematica's builtin documentation.
I am a PhD student in theoretical physics and almost everyone in our field has no choice but to use it (I do know one or two people that use maple, but the overwhelming majority chooses mathematica).
Despite its elegant design, many people hate it with a passion, as it has grown to be a huge bloated mess that takes forever to run. Also, due to the closed source nature, it is very hard to debug when something goes wrong. For example, it is quite often for the basic functions like `Simplify` and `Integrate` to get stuck running forever, but there is no way to keep track of the internal transformations that mathematica is doing, since everything is sealed up.
Based on my understanding of how expression evaluation works, the slightly more revealing statements would be "it is a lot of lisp macros" and "everything is an s-expression". Which means, a big mess. Let me expand:
As a functional programmer, "everything is an expression" sounds comforting, and I would expect there are clear transformation rules on how expressions are evaluated (and, maaybe, type signatures).
Instead, what you get is, "you can throw in some random form of expressions into this function, and it will do something with them". As in, it takes an AST input, and transforms them in some loosely specified way. There doesn't seem to be a type system, so you don't have types to guide you, rather you likely need to figure what kind of expressions work with which functions.
Now, if I'm wrong about this, and the functions behave consistently in what they take and how they transform it, then I'm more than open to be corrected. It is just that my high expectations (based on marketing of the lang) and the subsequent realization left me a bit bitter.
I do like that the lispy language itself closely mirrors math expressions, and it is consistently accessible throughout the user interface. For example, the mathematica notebook frontend (IDE) is simply some `MakeBoxes[]` of the expressions, which are all valid mathematica code themselves. I tried sympy a while ago, which I believe took an object-oriented approach, and it was very clumsy when compared to mathematica.
Still, I would not recommend using mathematica for general programming, precisely because of the mentioned shortcomings. By default, it is also impure and not lazy (eager eval, although it can be forced to be lazy on a case by case basis using `Hold` or `Unevaluated`).
f[x_Integer] := ...
will define a rule for f[] that only matches expressions where the argument to f[] has the head "Integer". It is even possible to use arbitrary predicates: vec3Q[v_] := VectorQ[v, NumberQ]&&Length[v]==3
f[v_?vec3Q] := ...
This lets you sort-of have type-checking. This is entirely opt-in, so you have to be somewhat rigorous about its use or it does not do any good. Also, in practice if any invocation of f[] does not have arguments which match the types for which you have defined it, the expression just remains unevaluated, which can create a mess (but maybe less of a mess than evaluating the function on input of the wrong form). The performance impact (particularly of the predicate version) is also non-zero, but my experience is that the biggest performance limitations come from trying to keep your machine from grinding to a halt when a runaway expression applied to the wrong thing explodes in complexity and eats all of your RAM... and this helps avoid that.While I have found this to be very helpful for writing and debugging hairy expressions, I used Mathematica for years before I even knew this was a thing. In reality almost no one does this, certainly not with any consistency, and the situation is as bad as you fear it would be.
Lisp-style macros are actually difficult to write because of the infinite evaluation of the language. I was able to write a quasiquote package for myself to help with that that though.
So I personally think it is perhaps not productive to think about type systems and type signatures when working with Mathematica. But you can definitively think in terms of transformation rules. And Mathematica either documents these rules or makes these rules intuitive.
I got my theoretical physics Ph.D. in 1987. I’ve never met anyone who uses Mathematica, except to try it out a bit out of curiosity. Perhaps you’re referring to a particular research group?
Starting as an undergrad, I extensively used mathematica to help or double check homework problems, plotting functions etc. For more "numerical" type of work, we extensively used matlab, so typically we used mathematica for more symbolical type problems. Later on, when working in physics, I often used mathematica, again mostly for doing things like symbolical integration, or things like quickly calculating symbolical gradients that I could copy-paste into some numerical software etc.
I no longer work in academia so I don't have access to a mathematica license, but similar free tools are Sympy, Maxima, which are good for basic stuff but in my experience are not nearly as good as Mathematica for more complicated stuff. Or just the online wolframalpha.
For example, my house experienced some flooding last year after exceptionally heavy rainfall. But how exceptional was it, really? I pulled out Mathematica and in a few minutes I had an interactive chart showing historical rainfall stats for my city over different time periods. The charting, interactivity, and weather APIs were all just built in.
I had a hunch that Ironman triathlon was advertising their races as having cooler weather than they actually do. Turns out I was right -- here's my [slowtwitch post](https://forum.slowtwitch.com/forum/Slowtwitch_Forums_C1/Tria...), and the [associated code](https://gist.github.com/latkin/470a2f06056ee0a8e3f4da837af10...).
I use it for symbolic calculation, solve differential equations, and many complicated integrals, and its visualizaion build upon those with easy parametrize support is very nice. Starting from my ungrad sophomore year as physics major, we have courses require us to finish some homeworks with Mathematica.
I can hardly find any other tool to replace mathematica in terms of symbolic calculation and doing complicated integrals (there is a joke by calling mathematica "large-scale integral table")
Mathematicians probably have trust issues and use tools with a code base that is 3 orders of magnitude smaller.
Its biggest flaw is how much it wants to act as a black box, which means when something goes wrong, or isn't exactly what you want, you spend more time trying to fix it than solving the original problem.
It's a powerful tool with a steep learning curve - hopefully the LLM assistant will help with this.
If the cost of that is shining Stephen Wolfram's dome, well, what can you do.
Other times I use it as a replacement for a calculator app, which feels exactly like cracking a walnut with a 500-ton industrial press.
It does have some reasonably unique capabilities that I did use more heavily in the past. E.g.:
- Simplifying the vector/matrix mathematics used in 3D graphics. It can eliminate redundant expressions, which is especially useful when you know that some of the inputs are constants such as 0 or 1.
- Non-linear curve fitting. If you have some complicated mathematical model you want to fit to noisy data, Mathematica will "just do it". With every other tool out there, this is... sss... hard.
- It missed the AI boat, but it has mostly caught up and could now be a viable alternative to the Python-based AI ecosystem, especially for certain areas of research.
- Complicated plotting requirements where I just can't be bothered spinning up some dedicated log analytics "tool" or subscribing to a "cloud service" and learning an entire query language just to draw a 3D histogram or whatever.
It has some strengths, but since its syntax highlighting is coupled to the kernel state it didn't have an undo function for the longest time. Also as big vim fan it's disappointing to not being able to use your favorite editor.
Edit: The github page for EIN says that development has stopped. Despite this, I was able to edit a notebook with only minor inconveniences very recently.
[1] Mathcad 2.0 Ad from 1987, the oldest I have found in 10 min. https://books.google.es/books?id=sc4TnHAYBSUC&pg=PA42
The basis my comment for this was this thread: https://news.ycombinator.com/item?id=22278637
Unfortunately the Atlantic article is now paywalled.
I was working on mathematical models (large scale optimization). These are usually solved numerically, and in numerical mathematics, how you write an equation matters tremendously (for instance, the equality x/y = z is much worse than x = y * z for solvers especially if y is a variable that can take on 0 as a value because during iteration this might create a lot of NaNs in your Jacobian or Hessian matrices).
I was using symbolic math to find better (but mathematically equivalent) ways to pose equations that would be numerically expedient. One example is using Groebner bases to do the equivalent of Gaussian elimination on a system of polynomial, which produces a row-echelon form and has many nice properties.
Nevertheless, I assume LLM enabled translators will improve rapidly, and that a product like Mathematica could be very well suited for translating from a prototype to a robust implementation for e.g. HPC.
It's unusual in the quant world though. I think they had hired a bunch of PhDs who had spent too much time in academia.
It's generally pretty nice for any sort of mathematical programming, from designing control systems to statistics to simple graphing. It's also a pretty good language for basic scripting and data manipulation. Most of the mathematical work on my blog is done in Mathematica.
[1] https://wxmaxima-developers.github.io/wxmaxima/download.html
It's a really pleasant environment for certain type of work.
The only thing missing is better type systems.
Mathematica is a computer algebra system at its core and is a rule-based rewrite system for expressions.
An example in Lisp notation:
In a computer algebra system (CAS) one may enter 5a - 2a
> (- (* 5 a) (* 2 a))
The CAS would answer with: (* 3 a)
It has used rules to simplify the expression and uses some default form. It could have printed a + a + a or 3 * a. It sees that it can't further simplify it, because a has no value and thus returns this simplified expression as it is.In Lisp things are differently. It takes an expression and tries to compute a value:
> (- (* 5 a) (* 2 a))
The result in Lisp is "Error: unbound variable a". It can't compute a value, because during evaluation it sees that the variable a has no value. Evaluation of the unbound variable a is an error.Now you could write an expression simplifier in Lisp: let's call it simplify. Lisp has a quote operator, which returns the embedded thing as it is -> it is not evaluated. We can embed an expression inside quote and thus call simplify with that unevaluated expression as an argument.
> (simplify (quote (- (* 5 a) (* 2 a))))
The result then could be (* 3 a)
One then could write a input loop in Lisp (loop (print (simplify (read)))
which then would not be a read-eval-print-loop, but a read-simplify-print-loop. (defun read-simplify-print-loop ()
(loop (print (simplify (read))))
This interactive loop would read expressions and print simplified expressions...Actually something like that has been done with computer algebra systems written in Lisp, like Macsyma/Maxima and Reduce. But they also then switched to infix syntax for input/output to make it easier for humans to enter mathematical expressions.
Peter Norvig gave in his book "Paradigms of AI Programming, Case Studies in Common Lisp" extensive examples how to implement such a thing in Lisp:
https://github.com/norvig/paip-lisp/blob/main/docs/chapter8....
and
https://github.com/norvig/paip-lisp/blob/main/docs/chapter15...
The advantage of the Mathematica language compared to Lisp is that it can compute with expressions via rules out of the box. Additionally Mathematica is so much more than that: it is an environment, a collection of mathematical knowledge, a cloud service, a specific product on can buy/rent, ...
The drawback is that the semantics are murky and Mathematica is a two-language system: the fast internal code (and much of the environment) is written in C++ and the expressive language is on top.
Lisp OTOH is often much more efficiently compiled with clear(er) semantics.
> > (- (* 5 a) (* 2 a))
> The CAS would answer with:
> (* 2 a)
Not sure I'd want to use such a CAS. Hint: 5-2 != 2. ;-)