Mathematica

Calculus

In the Mathematica examples below, boldface type is Input, regular type is Output.

Differentiation is always possible, but integration sometimes has to be done numerically instead of symbolically.

Derivative


   D[ Sin[x]-x^2, x ]

   -2 x + Cos[x]

Indefinite integral


   Integrate[ Sin[x]-x^2, x ]

   (-x^3 - 3 Cos[x])/3


   Integrate[ Sqrt[Sin[x]], x ]

   Integrate[ Sqrt[Sin[x]], x ]     (Can't do it symbolically!!)

Definite integral

A range can be specified for the variable(s) of integration. Multiple integrals are OK; specify the range of each. As indicated above, the integral is spit back unchanged if Mathematica is unable to simplify it.

   Integrate[ x^4, {x, 1, w} ]

   -1/5 + w^5/5


   Integrate[E^(-x^2-y^2), {x,0,Infinity}, {y,-Infinity,0}]

   Pi/4			(Double integral!! Infinite range!!)


   Integrate[ Log[k]^Sin[v], {k,2,3}, {v,0,1} ]

   Integrate[ Log[k]^Sin[v], {k,2,3}, {v,0,1} ]		(fails)

Definite integral (numerical)

Many integrals cannot be expressed in closed form, i.e. an expression cannot be integrated symbolically. Almost always, however, it can be integrated numerically to any desired degree of accuracy, using NIntegrate. One must give the bounds of integration.

   NIntegrate[ Sqrt[Sin[x]], {x, 0, Pi}]

   2.39628


   NIntegrate[ Log[k]^Sin[v], {k,2,3}, {v,0,1} ]

   0.956122


   NIntegrate[ Sqrt[Sin[x]], {x, 0, Pi}, WorkingPrecision->35]

   2.396280469471184414879845

Solve a differential equation symbolically


   DSolve[ y''[t]==3-y[t],  y[t],  t ]

   {{y[t] -> 3 + C[2] Cos[t] - C[1] Sin[t]}}


   DSolve[ {y''[t]==3-y[t], y[0]==10},  y[t],  t ]

   {{y[t] -> 3 + 7 Cos[t] - C[1] Sin[t]}}


See more on solving Ordinary Differential Equations
Table of Contents