# MuPAD

We first define a differential equation by defining it to be
an equation in the **ode** domain.

>> de:=ode(y'(x)+4*y(x)=exp(3*x),y(x)); ode(4 y(x) + diff(y(x), x) = exp(3 x), y(x))

Note that MuPAD supports the dash notation for the derivative.

>> solve(de); { 3 } { exp(x) } { ------- + C1 exp(-4 x) } { 7 }We can, of course, solve equations with initial conditions:

>> de2:=ode({y''(x)-2*y'(x)+3*y(x)=0,y(0)=1,y'(0)=2},y(x)); ode({D(y)(0) = 2, y(0) = 1, 3 y(x) - 2 diff(y(x), x) + diff(y(x), x, x) = 0 }, y(x)) >> solve(de2); { 1/2 1/2 } { 1/2 exp(x) 2 sin(x 2 ) } { exp(x) cos(x 2 ) + ----------------------- } { 2 }MuPAD will solve linear differential equations with little fuss, and also a large class of non-linear differential equations.

Recurrence relations are solved similarly; by defining an
equation to be of type **rec**, and applying the
command **solve**.

>> rr:=rec(a(n)=a(n-1)+3*a(n-2),a(n)); rec(a(n) = a(n - 1) + 3 a(n - 2), a(n)) >> solve(rr); { / 1/2 \n / 1/2 \n } { | 13 | | 13 | } { a1 | ----- + 1/2 | + a2 | 1/2 - ----- | } { \ 2 / \ 2 / }

If we include initial conditions, MuPAD will return the exact solution.

>> rr2:=rec(a(n)=a(n-1)+3*a(n-2),a(n),{a(0)=1,a(1)=3}); rec(a(n) = a(n - 1) + 3 a(n - 2), a(n), {a(0) = 1, a(1) = 3}) >> solve(rr2); { / 1/2 \ / 1/2 \n / 1/2 \ / 1/2 \n } { | 5 13 | | 13 | | 5 13 | | 13 | } { | 1/2 - ------- | | 1/2 - ----- | + | ------- + 1/2 | | ----- + 1/2 | } { \ 26 / \ 2 / \ 26 / \ 2 / }In the case of a non-homogeneous equation, MuPAD returns the particular solution.

>> rr3:=rec(a(n) = a(n - 1) + 3*a(n - 2)+n^2, a(n)); 2 rec(a(n) = a(n - 1) + 3 a(n - 2) + n , a(n)) >> solve(rr3); { 2 } { 14 n n } { - ---- - -- - 59/27 } { 9 3 }

Graphical display in MuPAD is produced by means of a separate
program called **VCam**, which can be
used entirely independent of MuPAD. But let's suppose we are in the
middle of a MuPAD session (started with xmupad), and we wish to
plot a few functions. The command **plotfunc** will
allow us to plot functions of the form y=f(x), or in three
dimensions, of the form z=f(x,y).

>> plotfunc(1/(1+x^2),x=-4..4); >> plotfunc(x^3-3*x*y^2,x=-2..2,y=-2..2);

Such commands will open up a VCam window with the function displayed in it, and also another window in which it is possible to change various plot options. The output of this second command is shown in Figure 2, along with various of VCams's windows.

**Figure 2. A
Screenshot of VCam in Action**

More general plot commands are **plot2d** and
**plot3d**, by which the above plots can be
generated as follows:

>> plot2d(Mode = Curve, [u, 1/(1+u^2)], u = [-4, 4]]); >> plot3d([Mode = Surface, [u, v, exp(-sqrt(u^2+v^2))], u = [-4, 4], v = [-4, 4]]);

We see that these commands use a parametric representation of the function. This allows for the easy plotting of a large number of different functions. There are a large number of plot options, including colours of plots and backgrounds, style of curves or surfaces, position and style of axes, labels and titles. All these can be changed interactively in VCam, or given as options to the plot command.

For a more complex example, let's plot a torus, with radii 3 and 1. This can be plotted with:

>> plot3d([Mode = Surface, [(3+cos(u))*cos(v), (3+cos(u))*sin(v), sin(u)], u = [0, 2*PI], v = [0, 2*PI]]);

This will give a wireframe torus with three numbered axes—not a particularly elegant result. We can add more options to this basic command to give us a nice filled-in torus with hidden lines, nestling in a box with no numbers:

>> plot3d(Title = "A torus", Axes = Box, Labels = ["","",""], Ticks = 0, [Mode = Surface, [(3+cos(u))*cos(v), (3+cos(u))*sin(v), sin(u)], u = [0, 2*PI], v = [0, 2*PI] Style = [ColorPatches, AndMesh]]);All these options can now be changed again with VCam. We can also change the perspective; zoom in and out; modify the colour scheme; and many other things. We can draw several surfaces at once, by placing multiple surface definitions in the one

**plot3d**command. For example:

>> plot3d(Title = "Two tori", Axes = Box, Labels = ["","",""], Ticks = 0, [Mode = Surface, [(5+cos(u))*cos(v), (5+cos(u))*sin(v), sin(u)], u = [0, 2*PI], v = [0, 2*PI], Style = [ColorPatches, AndMesh] ], [Mode = Surface, [sin(u), 5+(5+cos(u))*cos(v), (5+cos(u))*sin(v)], u = [0, 2*PI], v = [0, 2*PI], Style = [ColorPatches, AndMesh] ] );The result of this is shown in Figure 3.

**Figure 3. Two
Interlocking Tori**

When dealing with such long expressions as this, it is
convenient to first use your favorite editor to create a small
file, say “**tori.mu**”, to contain the above
command, then read it into MuPAD:

>> read("tori.mu");

This obviates using MuPAD's own text editing facilities, which are very basic.

## Trending Topics

## Webinar

### Fast/Flexible Linux OS Recovery

On Demand Now

In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.

Join *Linux Journal*'s Shawn Powers and David Huffman, President/CEO, Storix, Inc.

Free to *Linux Journal* readers.

Astronomy for KDE | Jun 23, 2016 |

Profiles and RC Files | Jun 22, 2016 |

Understanding Ceph and Its Place in the Market | Jun 21, 2016 |

SoftMaker FreeOffice | Jun 20, 2016 |

Git 2.9 Released | Jun 17, 2016 |

The Giant Zero, Part 0.x | Jun 16, 2016 |

- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Profiles and RC Files
- Astronomy for KDE
- Maru OS Brings Debian to Your Phone
- Understanding Ceph and Its Place in the Market
- Snappy Moves to New Platforms
- Git 2.9 Released
- OpenSwitch Finds a New Home
- What's Our Next Fight?
- The Giant Zero, Part 0.x

## Geek Guides

With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.

This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.

Get the Guide
## Comments

## Sellout

Mupad has been bought out by mathworks and all code is now under matlab (junk) licence.

any and all open source work is now dead.

## Thankyou for a well written a

Thankyou for a well written article. TeXmacs acts as an excellent interface to mupad. I assume that the TeXmacs screen display generated by TeX. The graphics is generated by javaview. The combination of TeXmacs and javaview greatly enhance the mupad experience.