# 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

## Enterprise Linux

Gabor Farkas' Practical GIS (Packt Publishing) | May 26, 2017 |

The Current Phase of the Moon | May 25, 2017 |

Mastering ATA over Ethernet | May 24, 2017 |

The Family Dashboard | May 23, 2017 |

Retro United Ltd.'s Write! | May 22, 2017 |

Wibu-Systems CmASIC | May 19, 2017 |

- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- The Current Phase of the Moon
- The Family Dashboard
- Mastering ATA over Ethernet
- Gabor Farkas' Practical GIS (Packt Publishing)
- SNMP
- Understanding Firewalld in Multi-Zone Configurations
- Simple Server Hardening
- A Switch for Your RPi
- The Weather Outside Is Frightful (Or Is It?)

## 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.