mathPAD Online

mathPAD Logo

The Magazine of the MuPAD Research Group, Vol. 15, Year 2006

MuPAD 4.0, what we will gain this time?

by M. Majewski

E-mail: mirek.majewski at mupad.com

Zayed University, United Arab Emirates

In the past, MuPAD has received a number of "best academic software" awards. The new version 4.0, coming sometime in summer 2006, proves that the MuPAD Research Team as well as MuPAD developers at SciFace Software - the commercial company developing and distributing MuPAD, are very skillful and manifest great research potential. The new MuPAD will surprise the users in many ways, and make our work more enjoyable then ever. In this short article I will show some new features in MuPAD 4.0 and try to explain the consequences of these features.

The new interface and new notebook

The first thing that we will notice after starting MuPAD is the new interface. It starts with a panel, where we can choose one of the recently edited notebooks, or start a new notebook.

Fig. 1 Starting panel of MuPAD 4.0

After choosing the notebook we want to use, we will see the new interface. The very first impression is that the interface seems familiar, but is completely new - there are new icons, a new sidebar, a new look, etc. In fact, the interface, the one that I had criticized many times in the past, has got an entirely new look. All the former functionality remains in the old places, but many things were simplified or were made more user-friendly. For instance, in the past saving graphics, animation or video required some knowledge about file formats, image resolution, keyframe frequency, etc. In the new MuPAD, the export wizard makes exporting such files as easy as possible by suggesting file formats and their properties, the number of frames in animations, etc. This way, creating a movie with an animated graph of a function in 3D is a very simple and straightforward task.

Another thing worth mentioning is the sidebar. This is where you'll find shortcuts to many MuPAD functions, procedures and plot classes. We can also find here things that used to be grouped in the extras menu in previous versions of MuPAD. Consequently, we do not have a separate extras menu any more.

Fig. 2 The new interface of MuPAD 4.0

Another important change is the new look of the notebook and its format. The notebook editing functionality was expanded in many ways. As before, we have three types of regions: text, input and output. However, in each of these regions we can apply formatting like in any good word processor. Therefore, we have many of these nice features like text wrapping, fonts and colors, tables, etc. This concept of editing resembles Scientific Workplace a bit. For instance, the line width is reformatted depending on the screen size, users can change the character size globally, etc. Preparing different versions of the same notebook is now a very simple task. We can make the same notebook with formatting convenient for working on the computer screen, or with large characters for a classroom presentation, or small characters for printing purposes. Text regions may contain tables, formulas, mathematical characters, etc.

One thing worth emphasizing is the integration of Virtual Camera with the notebook. We no longer need to open graphics in Virtual Camera in order to manipulate them. Just a click on the plot in the notebook automatically switches to the Virtual Camera; the new menu and icons appear on the interface and the sidebar changes to the graphics objects browser. We can then do with our plot everything that was possible in Virtual Camear before.

Finally, another thing that we will quickly notice is the new help. The help pages look like MuPAD notebooks, all the graphics embedded there are alive, we can manipulate them, preview animations, etc. Now, finally, the MuPAD help is printable and we can print each section of it. We can cut any part of the help file and paste it into a MuPAD notebook, recalculate MuPAD commands and produce plots. We can paste the content of the help file into any word processor and format it the way we need.

XML everywhere

I guess most MuPAD users will never appreciate that MuPAD uses XML formats for many things. However, MuPAD distributors will find this feature quite useful. For example, the majority of the MuPAD 4.0 interface text is hidden in XML files. The help files are also saved in XML format. The user configuration too, is saved as an XML file. All this makes life much easier for local distributors. For example, developing a Polish or Bulgarian version of MuPAD will be much easier than before. We no longer need MS Visual Studio to edit menu strings. Just a simple word processor or an XML file editor will be sufficient. Although there is still a number of messages buried in the main MuPAD file and in the libraries, the main menu as well as the sidebar can be easily localized.

Additionally, for a user with a basic knowledge of XML, it will be easy to create his own extras menu or extras library and add it to the sidebar. In fact, it would be possible to redesign the whole MuPAD menu this way.

New plots

For years, MuPAD graphics have been considered as the most impressive graphics out of all the available Computer Algebra Systems. Version 4.0 brings a few new plot classes, as well as a number of improvements and additions. There are four additions that I would particularly like to emphasize.

The class plot::Streamlines2d produces a plot of a 2D vector field showing the flow. Here is a simple example of what we can achieve with plot::Streamlines2d:

plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2-y^2),
    x = -2..2, y = -2..2,
    MinimumDistance = 0.1,
    TipLength = 2*unit::mm
  )
)


Another important plot improvement is the ability to plot graphs in 3D with an incomplete domain of a function. It happens quite frequently that functions are defined partially, due to negative values under the square root or division by zero for some values of arguments. Visualizing such functions was not always possible in earlier versions of MuPAD. It is possible now. Let us see an example showing how this looks in the practice.

The following code produces a plot with gaps in all places where the function F(x,y) was not defined;

F := plot::Function3d(sqrt(3*sin(x^2+y^2)), Mesh=[50,50]):
plot(F, Scaling=Constrained)

Yet another interesting thing in the MuPAD 4.0 plot library is the plot::Transform3d class. This class has in fact been there earlier, in version 3.1. However, not many people noticed its usefulness. The Transform3d class can be used to transform any plot using a 3x3 matrix. This way, for example, all possible projections can be done. The plot below shows the projection of a surface on its domain, the xy-plane.

f := plot::Function3d(exp(-x^2-y^2)*(cos(3*y)+sin(7*x)),
  x=-2..2, y=-2..2, 
  Submesh=[1,1], 
  FillColorFunction=((x, y, z) -> [(z+2)/4, 0.5, (2-z)/4])
):

graphLines:=plot::modify(f,
  Filled = FALSE,
  XLinesVisible = FALSE, 
  YLinesVisible = FALSE,
  ZContours = [Automatic, 15],
  LineColorFunction=((x, y, z) -> [(z+2)/4, 0.5, (2-z)/4])
):

linesProjection := plot::Transform3d(
  [0, 0, -1.5], // shift vector
  [1, 0, 0, // transformation matrix
   0, 1, 0,
   0, 0, 0],
  graphLines
):

plot(f,linesProjection)


Although the plot library in MuPAD 4.0 has a number of interesting additions, I will leave them for MuPAD users to explore. Here I will just mention one, the most recent addition. This is the Waterman polyhedra class. In fact, implementing Waterman polyhedra in MuPAD was a starting point to many other developments, like the random coloring of polyhedra, functions for the separate coloring of polyhedra faces, producing a convex hull from a set of points in 3D, and computing the Delaunay triangulation of a set of points.

In MuPAD 4.0, Waterman polyhedra can be generated for any radius and any center in 3D space. Here is an example of a Waterman polyhedron obtained in MuPAD. We create here the Waterman polyhedron with radius equal to 7 and the default center [0,0,0].

colors := [RGB::random() $ i = 1..120]:
plot(plot::Waterman(7, 
  FillColorFunction=((x,y,z,i) -> colors[i]))
)

Improved computational functionality

Although, we use computer algebra systems mainly for computing, changes in the computational functionality of MuPAD are the least visible. We have to dig in the libraries and produce a number of calculations to see what is new and what has been changed.

MuPAD 4.0 has a number of new procedures, and a lot of changes and improvements in existing procedures. Let me mention just a few things that I like in particular.

First, and the most important, we got a new solver. There is new mode for solving equations, inequalities, and systems of equations: when given the option Real, the solve procedure not only assumes the variable to solve for to be real, but also that all the intermediate results when inserting a solution into the original problem must be real.

Maybe not the most important, but certainly the most wanted is the change in the ordering of the terms in polynomials. Anyone who had used older versions of MuPAD will remember that sometimes MuPAD messed up the order of terms in a polynomial. Now, terms are ordered according to their powers. Therefore, we will get,

sum(x^n, n=0..5)


Another nice addition are piecewise results from many procedures. For example,

sum(a*x^n, n=0..100)

or

int(a*x^n, x=1..100)

Another serious improvement is the new | (read as 'evaluate at') operator. The operator allow us to calculate a given expression for a given value of argument. This operator is more valuable than the subs operator. As we remember the subs operator would substitute a given expression into a formula without bothering to check if the substitution makes sense or not. The | operator produces a mathematical result for the required substitution. For example:

subs(f(x,y), x="a", y="b")

You agree that the obtained result does not make any sense. However, if we try to do the same using the | operator then MuPAD will tell us that something our code is wrong, just like below,

f(x,y) | {x="a", y="b"}

Error: argument must be of type 'Type::Arithmetical' [cos]

We have got a number of new mathematical functions: Z transform and inverse Z transform, multivariate Taylor series expansion,  Fresnel integrals, elliptic integrals,  cosine and hyperbolic cosine integral functions,  sine and hyperbolic sine integral functions, Jacobian functions, and much more.

Finally, I have to mention that there are many improvements in factoring expressions, adding patterns to the integration process, enhanced symbolic both definite and indefinite integration as well as summation, enhanced simplification based on pattern matching, etc. There is no way to describe all the changes and additions in the computational part of MuPAD 4.0. I will leave these explorations to my readers. I believe the new MuPAD 4.0 will give us a lot of joy.

I am also sure that Steven Waterman will be very pleased with what MuPAD 4.0 can do for him in modeling his famous Waterman polyhedra.

Copyright © 2002-2007 mathPAD Online and the authors.