News, Views & Insights
Wolfram Language
Trees Continue to Grow 🌱🌳
Last year we released Version 13.0 of the Wolfram Language. Here are the updates in trees since then, including the latest features in 13.1.
Trees Continue to Grow 🌱🌳
In Version 12.3 we introduced Tree as a new fundamental construct in the Wolfram Language. In Version 13.0 we added a variety of styling options for trees, and in Version 13.1 we’re adding more styling as well as a variety of new fundamental features.
An important update to the fundamental Tree construct in Version 13.1 is the ability to name branches at each node, by giving them in an association:
✕
|
All tree functions now include support for associations:
✕
|
In many uses of trees the labels of nodes are crucial. But particularly in more abstract applications one often wants to deal with unlabeled trees. In Version 13.1 the function UnlabeledTree (roughly analogously to UndirectedGraph) takes a labeled tree, and basically removes all visible labels. Here is a standard labeled tree
✕
|
and here’s the unlabeled analog:
✕
|
In Version 12.3 we introduced ExpressionTree for deriving trees from general symbolic expressions. Our plan is to have a wide range of “special trees” appropriate for representing different specific kinds of symbolic expressions. We’re beginning this process in Version 13.1 by, for example, having the concept of “Dataset trees”. Here’s ExpressionTree converting a dataset to a tree:
✕
|
And now here’s TreeExpression “inverting” that, and producing a dataset:
✕
|
(Remember the convention that *Tree functions return a tree; while Tree* functions take a tree and return something else.)
Here’s a “graph rendering” of a more complicated dataset tree:
✕
|
The new function TreeLeafCount lets you count the total number of leaf nodes on a tree (basically the analog of LeafCount for a general symbolic expression):
✕
|
Another new function in Version 13.1 that’s often useful in getting a sense of the structure of a tree without inspecting every node is RootTree. Here’s a random tree:
✕
|
RootTree can get a subtree that’s “close to the root”:
✕
|
It can also get a subtree that’s “far from the leaves”, in this case going down to elements that are at level –2 in the tree:
✕
|
In some ways the styling of trees is like the styling of graphs—though there are some significant differences as a result of the hierarchical nature of trees. By default, options inserted into a particular tree element affect only that tree element:
✕
|
But you can give rules that specify how elements in the subtree below that element are affected:
✕
|
In Version 13.1 there is now detailed control available for styling both nodes and edges in the tree. Here’s an example that gives styling for parent edges of nodes:
✕
|
Options like TreeElementStyle determine styling from the positions of elements. TreeElementStyleFunction, on the other hand, determines styling by applying a function to the data at each node:
✕
|
This uses both data and position information for each node:
✕
|
In analogy with VertexShapeFunction for graphs, TreeElementShapeFunction provides a general mechanism to specify how nodes of a tree should be rendered. This named setting for TreeElementShapeFunction makes every node be displayed as a circle:
✕
|
Thanksgiving Day the Wolfram Way
Thanksgiving is a special day to celebrate family, friends and food. Preparation is key to a safe and delicious Thanksgiving dinner. Wolfram Language can help lower the stress and up the ease of your Thanksgiving Day preparations.
New in 13.1: Visual Effects and Beautification
Last year we released Version 13.0 of the Wolfram Language. Here are the updates in visual effects and beautification since then, including the latest features in 13.1.
Visual Effects & Beautification
At first it seemed like a minor feature. But once we’d implemented it, we realized it was much more useful than we’d expected. Just as you can style a graphics object with its color (and, as of Version 13.0, its filling pattern), now in Version 13.1 you can style it with its drop shadowing:
✕
|
✕
|
✕
|
✕ |
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
New in 13.1: Beyond Listability: Introducing Threaded
Last year we released Version 13.0 of the Wolfram Language. Here are the updates in listability since then, including the latest features in 13.1.
Beyond Listability: Introducing Threaded
From the very beginning of Mathematica and the Wolfram Language we’ve had the concept of listability: if you add two lists, for example, their corresponding elements will be added:
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
✕
|
New in 13.1: College and Fractional Calculus
Last year we released Version 13.0 of the Wolfram Language. Here are the updates in college and fractional calculus since then, including the latest features in 13.1.
College Calculus
Transforming college calculus was one of the early achievements of Mathematica. But even now we’re continuing to add functionality to make college calculus ever easier and smoother to do—and more immediately connectable to applications. We’ve always had the function D for taking derivatives at a point. Now in Version 13.1 we’re adding ImplicitD for finding implicit derivatives.
So, for example, it can find the derivative of xy with respect to x, with y determined implicit by the constraint x2 + y2 = 1:
✕
|
Leave out the first argument and you’ll get the standard college calculus “find the slope of the tangent line to a curve”:
✕
|
So far all of this is a fairly straightforward repackaging of our longstanding calculus functionality. And indeed these kinds of implicit derivatives have been available for a long time in Wolfram|Alpha. But for Mathematica and the Wolfram Language we want everything to be as general as possible—and to support the kinds of things that show up in differential geometry, and in things like asymptotics and validation of implicit solutions to differential equations. So in addition to ordinary college-level calculus, ImplicitD can do things like finding a second implicit derivative on a curve defined by the intersection of two surfaces:
✕
|
In Mathematica and the Wolfram Language Integrate is a function that just gets you answers. (In Wolfram|Alpha you can ask for a step-by-step solution too.) But particularly for educational purposes—and sometimes also when pushing boundaries of what’s possible—it can be useful to do integrals in steps. And so in Version 13.1 we’ve added the function IntegrateChangeVariables for changing variables in integrals.
An immediate issue is that when you specify an integral with Integrate[...], Integrate will just go ahead and do the integral:
✕
|
But for IntegrateChangeVariables you need an “undone” integral. And you can get this using Inactive, as in:
✕
|
And given this inactive form, we can use IntegrateChangeVariables to do a “trig substitution”:
✕
|
The result is again an inactive form, now stating the integral differently. Activate goes ahead and actually does the integral:
✕
|
IntegrateChangeVariables can deal with multiple integrals as well—and with named coordinate systems. Here it’s transforming a double integral to polar coordinates:
✕
|
Although the basic “structural” transformation of variables in integrals is quite straightforward, the whole story of IntegrateChangeVariables is considerably more complicated. “College-level” changes of variables are usually carefully arranged to come out easily. But in the more general case, IntegrateChangeVariables ends up having to do nontrivial transformations of geometric regions, difficult simplifications of integrands subject to certain constraints, and so on.
In addition to changing variables in integrals, Version 13.1 also introduces DSolveChangeVariables for changing variables in differential equations. Here it’s transforming the Laplace equation to polar coordinates:
✕
|
Sometimes a change of variables can just be a convenience. But sometimes (think General Relativity) it can lead one to a whole different view of a system. Here, for example, an exponential transformation converts the usual Cauchy–Euler equation to a form with constant coefficients:
✕
|
Fractional Calculus
The first derivative of x2 is 2x; the second derivative is 2. But what is the derivative? It’s a question that was asked (for example by Leibniz) even in the first years of calculus. And by the 1800s Riemann and Liouville had given an answer—which in Version 13.1 can now be computed by the new FractionalD:
✕
|
And, yes, do another derivative and you get back the 1st derivative:
✕
|
In the more general case we have:
✕
|
And this works even for negative derivatives, so that, for example, the (–1)st derivative is an ordinary integral:
✕
|
It can be at least as difficult to compute a fractional derivative as an integral. But FractionalD can still often do it
✕
|
though the result can quickly become quite complicated:
✕
|
Why is FractionalD a separate function, rather than just being part of a generalization of D? We discussed this for quite a while. And the reason we introduced the explicit FractionalD is that there isn’t a unique definition of fractional derivatives. In fact, in Version 13.1 we also support the Caputo fractional derivative (or differintegral) CaputoD.
For the derivative of x2, the answer is still the same:
✕
|
But as soon as a function isn’t zero at x = 0 the answer can be different:
✕
|
CaputoD is a particularly convenient definition of fractional differentiation when one’s dealing with Laplace transforms and differential equations. And in Version 13.1 we can now only compute CaputoD but also do integral transforms and solve equations that involve it.
Here’s a -order differential equation
✕
|
and a -order one
✕
|
as well as a πth-order one:
✕
|
Note the appearance of MittagLefflerE. This function (which we introduced in Version 9.0) plays the same kind of role for fractional derivatives that Exp plays for ordinary derivatives.
Winners of the 2022 One-Liner and Get Visual Competitions
New in 13.1: Chemical Representations and Pattern Reactions
Last year we released Version 13.0 of the Wolfram Language. Here are the updates in chemical representations and symbolic pattern reactions since then, including the latest features in 13.1.
Representing Amounts of Chemicals
Molecule lets one symbolically represent a molecule. Quantity lets one symbolically represent a quantity with units. In Version 13.1 we now have the new construct ChemicalInstance that’s in effect a merger of these, allowing one to represent a certain quantity of a certain chemical.Should I Eat That? Food Safety with Wolfram Language
September is Food Safety Education Month. To highlight the importance of food safety, we have introduced two new properties in Wolfram Language that can help users make smart choices about food storage: