Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Use the MuPAD Libraries

Overview of Libraries

Libraries contain most of the MuPAD® functionality. Each library includes a collection of functions for solving particular types of mathematical problems:

combinatsupports combinatorics operations
solvelibcontains various methods used by the function solve
exportsupports exporting MuPAD data to external formats
outputsupports formatted output of the MuPAD data
fpsupports functional programming methods
generatesupports conversion of the MuPAD expressions to C, FORTRAN, MATLAB®, and TeX codes
groebnersupports operating on ideals of multivariate polynomial rings over a field
importsupports importing external data to MuPAD
transformsupports integral transformations and the discrete Z-transform
intlibsupports manipulating and solving integrals
linalgsupports linear algebra operations
linoptprovides algorithms for linear and integer programming
listlibsupports manipulating lists
polylibsupports manipulating polynomials
stringlibsupports manipulating strings
numlibsupports number theory operations
numericprovides algorithms for numeric mathematics
odesupports manipulating and solving ordinary differential equations
orthpolyprovides a set of standard orthogonal polynomials
Prefsupports setting and restoring user preferences
progprovides programming utilities for analyzing functions and tracing errors
statsprovides methods for statistical analysis
Typesupports checking types of MuPAD objects
Symbolsupports typesetting symbols

Functions included in libraries are written in the MuPAD language. The calling syntax for functions from all the libraries (except for the standard library) includes both the library name and the function name: library::function.

Standard Library

The standard library presents the set of most frequently used functions including diff, int, simplify, solve, and other functions. For example:

diff(x^2,x)

Find Information About a Library

You can get information about the libraries using the info and help commands. The info command gives a list of functions of a particular library. For example, the numlib library presents a collection of functions for number theory operations:

info(numlib)
Library 'numlib': the package for elementary number theory
-- Interface:
numlib::Lambda,          numlib::Omega,            numlib::checkPrimalityCertificate,
numlib::contfrac,        numlib::contfracPeriodic, numlib::cornacchia,
numlib::decimal,         numlib::divisors,         numlib::factorGaussInt,
numlib::fibonacci,       numlib::fromAscii,        numlib::g_adic,
numlib::ichrem,          numlib::igcdmult,         numlib::invphi,
numlib::ispower,         numlib::isquadres,        numlib::issqr,
numlib::jacobi,          numlib::lambda,           numlib::legendre,
numlib::lincongruence,   numlib::mersenne,         numlib::moebius,
numlib::mroots,          numlib::msqrts,           numlib::numdivisors,
numlib::numprimedivisors, numlib::omega,            numlib::order,
numlib::phi,             numlib::pi,               numlib::primedivisors,
numlib::primroot,        numlib::proveprime,       numlib::reconstructRational,
numlib::sigma,           numlib::sqrt2cfrac,       numlib::sqrtmodp,
numlib::sumOfDigits,     numlib::sumdivisors,      numlib::tau,
numlib::toAscii,                                                                     

To see brief information about a particular library function, use the mouse pointer to hover the cursor over the function name.

For more information about the library and for information about the library functions, enter:

?numlib

To see the implementation of a library function, use the expose command:

expose(numlib::tau)
proc(a)
  name numlib::tau;
begin
  if args(0) <> 1 then
    error(message("symbolic:numlib:IncorrectNumberOfArguments"))
  else
    if not testtype(a, Type::Numeric) then
      return(procname(args()))
    else
      if domtype(a) <> DOM_INT then
        error(message("symbolic:numlib:ArgumentInteger"))
      end_if
    end_if
  end_if;
  numlib::numdivisors(a)
end_proc

Avoid Name Conflicts Between MuPAD Objects and Library Functions

You can call any library function (except for the standard library functions) using the following syntax: library::function. If you frequently use some functions that do not belong to the standard library, it is possible to call them without specifying the library name. The use command exports functions of the MuPAD libraries to the global namespace allowing you to call them without using the library names. For example, you can export the function that computes the decimal expansion of a rational number:

use(numlib,decimal): decimal(1/3)

After exporting the decimal function, you can use it without using the library name numlib:

decimal(1/200)

To call the info, help, or ? commands, use the full name of an exported function including the name of a library:

?numlib::decimal

You cannot export a library function with the same name you use for another object:

hilbert := x: use(linalg, hilbert)
Warning: Identifier 'hilbert' already has a value. It is not exported. [use]

After clearing the variable decimal, you can export a function:

delete hilbert: use(linalg, hilbert): hilbert(3)

You also can export several functions from the same library simultaneously. For example, you can export the functions for finding the sum of digits and the set of positive divisors of an integer:

use(numlib, sumOfDigits, divisors): divisors(21); sumOfDigits(21)

To export all functions of a library, pass the library name to the use command. If some of the library functions have name conflicts with other objects, the use command issues a warning for each name conflict:

use(numeric)
Warning: Identifier 'product' already has a value. It is not exported. [use]
Warning: Identifier 'int' already has a value. It is not exported. [use]
Warning: Identifier 'indets' already has a value. It is not exported. [use]
Warning: Identifier 'det' already has a value. It is not exported. [use]
Warning: Identifier 'linsolve' already has a value. It is not exported. [use]
Warning: Identifier 'rationalize' already has a value. It is not exported. [use]
Warning: Identifier 'inverse' already has a value. It is not exported. [use]
Warning: Identifier 'solve' already has a value. It is not exported. [use]
Warning: Identifier 'sum' already has a value. It is not exported. [use]
Warning: Identifier 'sort' already has a value. It is not exported. [use]

These library functions have the same names as the standard library functions. You cannot delete standard library functions and resolve the name conflicts. Use the full function names such as numeric::product to call these functions.

Was this topic helpful?