This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Add-ons / Standard Packages / Introduction  /

Calculus Packages

Mathematica has extensive built-in support for calculus, including integration, differentiation, differential equation solving, and limits. The Calculus packages extend this functionality by providing Fourier and Laplace integral transforms, the unit step function, and the Dirac delta. There are packages for finding complete integrals of differential equations, computing Padé approximations, and doing vector operations in various three-dimensional coordinate systems. The package VariationalMethods is useful for solving for a function extremizing a definite integral functional, a problem that appears in many areas of physics and engineering.

  • This causes each Calculus package to load as needed.
  • In[1]:= <<Calculus`

  • Piecewise functions can be defined using UnitStep. Here is a piecewise function that decays like for , decays like for , and has a singularity at . The singularity happens to be missed by the sampling of Plot

  • In[2]:= (piecewise[t_] := Exp[- t] (UnitStep[t-1] - UnitStep[t-5]) +
    Exp[- t/2] UnitStep[t-5] + DiracDelta[t-2];
    Plot[piecewise[t], {t, 0, 10},
    PlotRange -> All])


  • You can integrate functions involving UnitStep or DiracDelta. Note that the delta at

    causes the step discontinuity in the integrated function.
  • In[3]:= (int = Integrate[piecewise[t], t];
    Plot[int, {t, 0, 10}, PlotRange -> All])


  • You can solve differential equations directly using the built-in function DSolve.
  • In[4]:= (de = g''[t] + 3*g[t] == Sin[5*t];
    Simplify[DSolve[{de, g[0] == 0, g'[0] == 0}, g[t], t]])


  • Or you can solve them using the Laplace transform.
  • In[5]:= laplacetrans = (LaplaceTransform[de, t, s] /.
    {g[0] -> 0, g'[0] -> 0})


    In[6]:= (solve = Solve[laplacetrans, LaplaceTransform[g[t], t, s]];
    Simplify[InverseLaplaceTransform[solve, s, t]])


    The function VariationalBound can be used to give an upper bound on the first eigenvalue associated with the vibrating string problem. Here assume that the string has unit length, density, and tension. The integral is minimized over all approximating eigenfunctions

    having the same form as the specified trial function.

  • For a vibrating string with a fixed end at , a trial function is picked such that . The parameter

    is chosen to satisfy a normalization condition.
  • In[7]:= (phitrial = a x^k;
    eq = (Integrate[phitrial^2, {x, 0, 1},
    Assumptions -> {k > 1/2}] == 1);
    phitrial = (phitrial /. Solve[eq, a])[[1]])


  • The bound is , close to the precise value

  • In[8]:= VariationalBound[D[phi[x], x]^2,
    phi[x], {x, 0, 1}, phitrial, {k}]