Walkthrough with Mathematica Key Technologies

Rob Knapp

Wolfram Research, Inc.

Initialization

$Path  =  
        Join[$Path,  {"C:\\Documents and Settings\\rknapp\\My \
Documents\\Talks\\Paris"}];

Key Technologies

A search for "Key Technologies" on www.wolfram.com gives the short list:

• Symbolic Programming

• Numerics

• Depth of Algorithmic Knowledge

• Automatic Algorithm Selection

• Notebook Document-Centered Interface

• Fully Interactive Math Typesetting

• Symbolic XML

The talk is somewhat misnamed:  to describe even a subset of these in 30 minutes will be more at the pace of a brisk run.

Key Technologies

This talk will focus on a few of the most important key technologies which are the building blocks that have allowed Mathematica to hold a preeminent position in general technical computing.

• Symbolic Programming -- Symbolic Expressions -- several examples.

• Numerics -- Automatic switch between exact, arbitrary precision, and hardware arithmetic.

• Depth of Algorithmic Knowledge -- Minimization and PDE examples.

• Automatic Algorithm Selection -- Minimization and PDE examples.

• Notebook Document-Centered Interface

• Fully Interactive Math Typesetting

• Symbolic XML

The keystone idea.

One idea which unifies Mathematica is the concept of a symbolic expression.  All commands, functions, and objects in Mathematica have some representation as a symbolic expression.  Think of this as the solid bedrock on which Mathematica is built.

Symbolic expressions

A simple example to demonstrate the idea of a symbolic expression is the quadratic formula.

((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a))

Symbolic expressions

A simple example to demonstrate the idea of a symbolic expression is the quadratic formula.

((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a))

Though it displays in a nice typeset form, Mathematica uses something not quite so visually pleasing for its practical basic representation.

FullForm[((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a)) ]

Symbolic expressions

A simple example to demonstrate the idea of a symbolic expression is the quadratic formula.

((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a))

Though it displays in a nice typeset form, Mathematica uses something not quite so visually pleasing for its practical basic representation.

FullForm[((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a)) ]

Everything in Mathematica has a basic representation of this type.

Mathematica's operation consists of evaluating symbolic expressions.

Symbolic expressions

Matrix

Here is a matrix

(({{"Conrad", "Introduction", "9:30", 30}, {"Rob", "Key", "10:00", 30}, {"Tom", "Deploy", "10:30", 30}, {"Break", "Café", "11:00", 30}}))

Symbolic expressions

Matrix

Here is a matrix

(({{"Conrad", "Introduction", "9:30", 30}, {"Rob", "Key", "10:00", 30}, {"Tom", "Deploy", "10:30", 30}, {"Break", "Café", "11:00", 30}}))

Here is its symbolic form

FullForm[(({{"Conrad", "Introduction", "9:30", 30}, {"Rob", "Key", "10:00", 30}, {"Tom", "Deploy", "10:30", 30}, {"Break", "Café", "11:00", 30}}))]

Symbolic expressions

Sum

Here is a simple sum of terms

2  +  a  +  5  +  2 a

Symbolic expressions

Sum

Here is a simple sum of terms

2  +  a  +  5  +  2 a

Here is its symbolic form without evaluation

FullForm[
      Unevaluated[2  +  a  +  5  +  2 a]]

Symbolic expressions

Sum

Here is a simple sum of terms

2  +  a  +  5  +  2 a

Here is its symbolic form without evaluation

FullForm[
      Unevaluated[2  +  a  +  5  +  2 a]]

Here is its symbolic form after evaluation

FullForm[2  +  a  +  5  +  2 a]

Symbolic expressions

Sum

Here is a simple sum of terms

2  +  a  +  5  +  2 a

Here is its symbolic form without evaluation

FullForm[
      Unevaluated[2  +  a  +  5  +  2 a]]

Here is its symbolic form after evaluation

FullForm[2  +  a  +  5  +  2 a]

Evaluation executes commands and brings symbolic expression to canonical forms.  When evaluating, functions with recognized names or ones defined by users are executed.

In this example, the command Plus executes, adding the integers and combining the symbolic terms into a simpler form.

Symbolic Programming

Rules

A rule defines a substitution for symbolic expressions.  In Mathematica, it has the notation lhs->rhs giving a substitution for something matching lhs into rhs.

This substitutes numbers into the quadratic formula

((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a))  /.  {a -> 1,  b -> -4,  c -> 3}

Symbolic Programming

Rules

A rule defines a substitution for symbolic expressions.  In Mathematica, it has the notation lhs->rhs giving a substitution for something matching lhs into rhs.

This substitutes numbers into the quadratic formula

((-b  ±  (Sqrt[(b^2) -  4 a c]))/(2 a))  /.  {a -> 1,  b -> -4,  c -> 3}

This gets the two individual solutions

%  /.  {{PlusMinus -> Plus}, {PlusMinus -> 
            Subtract}}

Symbolic Programming

Notebook documents

Yes, these have representations as symbolic expressions also and can be manipulated with symbolic programming.

Symbolic Programming

Notebook documents

Yes, these have representations as symbolic expressions also and can be manipulated with symbolic programming.

Entering this will do a quick review of the talk for you:

FrontEndExecute[{FrontEndToken[
            FrontEnd`SelectedNotebook[], "ScrollPageFirst"]}];
Pause[1. ]; 
    Do[FrontEndExecute[{FrontEndToken[
            FrontEnd`SelectedNotebook[], "ScrollPageNext"]}];  
      Pause[2. /i], {i, 17}]

Symbolic Programming

Graphics

Graphics objects have representations as symbolic objects that can be transformed.

Symbolic Programming

Graphics

Graphics objects have representations as symbolic objects that can be transformed.

This loads a package that contains definitions for constructing polyhedra.

Needs["Graphics`Polyhedra`"]

Symbolic Programming

Graphics

Graphics objects have representations as symbolic objects that can be transformed.

This loads a package that contains definitions for constructing polyhedra.

Needs["Graphics`Polyhedra`"]

This generates a symbolic expression for a graphical image of a stellated dodecahedron.

dodo  =  Stellate[Polyhedron[Dodecahedron]]

Symbolic Programming

Graphics

Graphics objects have representations as symbolic objects that can be transformed.

This loads a package that contains definitions for constructing polyhedra.

Needs["Graphics`Polyhedra`"]

This generates a symbolic expression for a graphical image of a stellated dodecahedron.

dodo  =  Stellate[Polyhedron[Dodecahedron]]

The complete form of it is not shown by default because most often you want to see the image, which can be generated with Show.

Show[dodo];

Symbolic Programming

Graphics

Here is the full form of the expression.

FullForm[dodo]

Symbolic Programming

Graphics

The object consists of Polygon graphics primitives, so if we make a rule which will transform Polygons, we can transform the image.

Symbolic Programming

Graphics

The object consists of Polygon graphics primitives, so if we make a rule which will transform Polygons, we can transform the image.

This defines a function which simply shrinks a polygon down by a given factor.

Shrink[Polygon[v_],  f_]  :=  
      Module[{m  =  Mean[v] (1  -  f)},  
        Polygon[Map[(m  +  f #) &,  v]]]

Symbolic Programming

Graphics

The object consists of Polygon graphics primitives, so if we make a rule which will transform Polygons, we can transform the image.

This defines a function which simply shrinks a polygon down by a given factor.

Shrink[Polygon[v_],  f_]  :=  
      Module[{m  =  Mean[v] (1  -  f)},  
        Polygon[Map[(m  +  f #) &,  v]]]

Note that this is a simple program which is itself a symbolic expression.

Symbolic Programming

Graphics

The object consists of Polygon graphics primitives, so if we make a rule which will transform Polygons, we can transform the image.

This defines a function which simply shrinks a polygon down by a given factor.

Shrink[Polygon[v_],  f_]  :=  
      Module[{m  =  Mean[v] (1  -  f)},  
        Polygon[Map[(m  +  f #) &,  v]]]

Note that this is a simple program which is itself a symbolic expression.

This substitutes every polygon in the dodecahedron with its shrunken version.

Show[
        dodo  /.  p_Polygon :> Shrink[p,  .8]];

Symbolic Expressions and Automatic Algorithm Selection

I hope by now you are convinced about the generality and flexibility of symbolic expressions and programming.

Now I want to show you some examples of the leverage that Mathematica can get towards algorithm selection by working with symbolic expressions.

Symbolic Expressions and Automatic Algorithm Selection

Arithmetic

Mathematica's arithmetic provides a simple example of automatic algorithm selection.

Symbolic Expressions and Automatic Algorithm Selection

Arithmetic

Mathematica's arithmetic provides a simple example of automatic algorithm selection.

Consider the problem of multiplying two things together.

Multiplication

• If one or both are symbolic, then attempts are made to reduce the result to a canonical form.

a*a

Multiplication

• If both are machine integers, hardware arithmetic is used, if possible.

101*444

Multiplication

• Arbitrary sized integers use GMP multiplication routines, which for large size use transform methods to achieve O(n log n) complexity.

Factorial[10000]

Multiplication

•If both are arbitrary precision approximate numbers, multiplication is similarly handled with GMP but with the precision of the result computed with significance arithmetic.

N[Pi,  10]*N[E,  20]

Multiplication

•If both are arbitrary precision approximate numbers, multiplication is similarly handled with GMP but with the precision of the result computed with significance arithmetic.

N[Pi,  10]*N[E,  20]

The precision of the result is, in this case, the lesser of the two input precisions.

Precision[%]

Multiplication

•If both are arbitrary precision approximate numbers, multiplication is similarly handled with GMP but with the precision of the result computed with significance arithmetic.

N[Pi,  10]*N[E,  20]

The precision of the result is, in this case, the lesser of the two input precisions.

Precision[%]

Software arithmetic with automatic precision control can be useful where having an assurance of good results is important.

Multiplication

•For mixed arithmetic, numerical coercion is applied before computing the product.

3.14*(1/Pi)

The whole process is handled by dispatching to appropriate functions, which themselves may dispatch off to different functions depending on problem size and type.

Symbolic Expressions and Automatic Algorithm Selection

Minimizing a function

This loads a collection of standard test problems for unconstrained local optimization.

<< Optimization`UnconstrainedProblems`

The following minimization problem is the so-called "Rosenbrock"  problem, commonly used to check on local optimization methods in low dimensions.  It difficulty lies in a curved valley: simple descent methods do quite poorly on this problem.

p  =  GetFindMinimumProblem[Rosenbrock]

Minimizing a function

The collection of problems also includes a function FindMinimumPlot which, for problems in two variables shows the steps and function evaluations used to solve the minimization problem.

This shows the steps and evaluations used by the method Mathematica chooses automatically.

p1  =  
      FindMinimumPlot[(((1 - (Subscript[X, 1])))^2) + 
          100 (((-(Subscript[X, 1]^2) + (Subscript[X, 2])))^2), {{(Subscript[X, 1]), -1.2`}, {(Subscript[X, 2]), 
            1.`}}]

Minimizing a function

The collection of problems also includes a function FindMinimumPlot which, for problems in two variables shows the steps and function evaluations used to solve the minimization problem.

This shows the steps and evaluations used by the method Mathematica chooses automatically.

p1  =  
      FindMinimumPlot[(((1 - (Subscript[X, 1])))^2) + 
          100 (((-(Subscript[X, 1]^2) + (Subscript[X, 2])))^2), {{(Subscript[X, 1]), -1.2`}, {(Subscript[X, 2]), 
            1.`}}]

The reason that the reported evaluations include residual and Jacobian is because Mathematica has detected symbolically that the function is a sum of squares, so it is possible to use the Levenberg-Marquardt method, which is a Gauss-Newton method based on working with the residual vector r such that f = r . r.  The residual function is found symbolically in this case.

Minimizing a function

This shows how it does with Newton's method.

p2  =  
      FindMinimumPlot[(((1 - (Subscript[X, 1])))^2) + 
          100 (((-(Subscript[X, 1]^2) + (Subscript[X, 2])))^2), {{(Subscript[X, 1]), -1.2`}, {(Subscript[X, 2]), 
            1.`}},  Method -> Newton]

Minimizing a function

This shows how it does with the BFGS quasi-Newton method.

p3  =  
      FindMinimumPlot[(((1 - (Subscript[X, 1])))^2) + 
          100 (((-(Subscript[X, 1]^2) + (Subscript[X, 2])))^2), {{(Subscript[X, 1]), -1.2`}, {(Subscript[X, 2]), 
            1.`}},  Method -> QuasiNewton]

Minimizing a function

An additional advantage Mathematica has is that it can compute derivatives symbolically.  Below is the method that would be used by default if the function were presented as a black box.  (It uses a quasi-Newton method with derivatives computed by finite differences.  There is also a method designed to be derivative free.)

p4  =  
      FindMinimumPlot[(((1 - (Subscript[X, 1])))^2) + 
          100 (((-(Subscript[X, 1]^2) + (Subscript[X, 2])))^2), {{(Subscript[X, 1]), -1.2`}, {(Subscript[X, 2]), 
            1.`}},  Method -> QuasiNewton,  
        Gradient -> "FiniteDifference"]

Minimizing a function

Here is a summary showing all the plots together and all the information.

Show[
      GraphicsArray[(pall  =  {p1, p2, p3, 
                p4})[[All, -1]]]]

Symbolic Expressions and Automatic Algorithm Selection

Solving a PDE

Solution of partial differential equations provides a more sophisticated example of Mathematica's automatic algorithm selection.

This computes a solution for the sine-Gordon equation.

L  =  10;

sol = NDSolve[{(((∂^2) u(t, 
                        x))/(∂t ∂t))==(((∂^2) u(t, 
                          x))/(∂x ∂x))+sin(u(t, x)),
u(0, 
                    x) == (E^(-(x^2))),(((∂u(t, 
                            x))/(∂t))/.t -> 0)==0,
u(t, -L) == u(t, L)},
u,{t, 0, L},{x, -L, L}]

Symbolic Expressions and Automatic Algorithm Selection

Solving a PDE

Solution of partial differential equations provides a more sophisticated example of Mathematica's automatic algorithm selection.

This computes a solution for the sine-Gordon equation.

L  =  10;

sol = NDSolve[{(((∂^2) u(t, 
                        x))/(∂t ∂t))==(((∂^2) u(t, 
                          x))/(∂x ∂x))+sin(u(t, x)),
u(0, 
                    x) == (E^(-(x^2))),(((∂u(t, 
                            x))/(∂t))/.t -> 0)==0,
u(t, -L) == u(t, L)},
u,{t, 0, L},{x, -L, L}]

The solution is returned as a rule giving u in terms of an InterpolatingFunction, which uses the data generated by the solver to give a continuous approximation to the solution over the rectangle [0,L]x[-L,L].

Symbolic Expressions and Automatic Algorithm Selection

Solving a PDE

Solution of partial differential equations provides a more sophisticated example of Mathematica's automatic algorithm selection.

This computes a solution for the sine-Gordon equation.

L  =  10;

sol = NDSolve[{(((∂^2) u(t, 
                        x))/(∂t ∂t))==(((∂^2) u(t, 
                          x))/(∂x ∂x))+sin(u(t, x)),
u(0, 
                    x) == (E^(-(x^2))),(((∂u(t, 
                            x))/(∂t))/.t -> 0)==0,
u(t, -L) == u(t, L)},
u,{t, 0, L},{x, -L, L}]

The solution is returned as a rule giving u in terms of an InterpolatingFunction, which uses the data generated by the solver to give a continuous approximation to the solution over the rectangle [0,L]x[-L,L].

The IntepolatingFunction can be used to plot the solution.

Plot3D[
        Evaluate[u[t, x]  /.  First[sol]],  {t, 0, L}, {x, -L, 
          L}];

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

Next I will describe some of the important steps and choices that are made automatically along the way to a solution.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2)u(t, x))/(∂t ∂t))==(((∂^2)u(t, x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

• Next derivative orders are determined in each dimension.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u (0, x) == (E^(-(x^2))),(((∂u(t, 
                            x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

• Next derivative orders are determined in each dimension.

• The method currently implemented is the numerical method of lines, where a (spatial) discretization is done in all but one independent (temporal) variable.  
   At this stage of the solution, a temporal variable is chosen.  Here the choice is fairly straightforward because one dimension (t) has initial conditions while
   the other (x) has boundary conditions.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

• Next derivative orders are determined in each dimension.

• The method currently implemented is the numerical method of lines, where a (spatial) discretization is done in all but one independent (temporal) variable.  
   At this stage of the solution, a temporal variable is chosen.  Here the choice is fairly straightforward because one dimension (t) has initial conditions while
   the other (x) has boundary conditions.

• Next, the system is symbolically expressed as a system of one independent variable: ((Subscript[U, 0]))''(t)== (𝔻^2) (Subscript[U, 0])(t) + 
            sin((Subscript[U, 0])(t))
   (𝔻^2) represents the operator which approximates the second order x derivative.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

• Next derivative orders are determined in each dimension.

• The method currently implemented is the numerical method of lines, where a (spatial) discretization is done in all but one independent (temporal) variable.  
   At this stage of the solution, a temporal variable is chosen.  Here the choice is fairly straightforward because one dimension (t) has initial conditions while
   the other (x) has boundary conditions.

• Next, the system is symbolically expressed as a system of one independent variable: ((Subscript[U, 0]))''(t)== (𝔻^2) (Subscript[U, 0])(t) + 
            sin((Subscript[U, 0])(t))
   (𝔻^2) represents the operator which approximates the second order x derivative.

• The system is converted to first order: ((Subscript[U, 1]))'(t)== (𝔻^2) (Subscript[U, 0])(t) + 
              sin((Subscript[U, 0])(t)), U' (t)  ==  (Subscript[U, 1])(t)

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

• Next derivative orders are determined in each dimension.

• The method currently implemented is the numerical method of lines, where a (spatial) discretization is done in all but one independent (temporal) variable.  
   At this stage of the solution, a temporal variable is chosen.  Here the choice is fairly straight forward because one dimension (t) has initial conditions while
   the other (x) has boundary conditions.

• Next, the system is symbolically expressed as a system of one independent variable: ((Subscript[U, 0]))''(t)== (𝔻^2) (Subscript[U, 0])(t) + 
            sin((Subscript[U, 0])(t))
   (𝔻^2) represents the operator which approximates the second order x derivative.

• The system is converted to first order: ((Subscript[U, 1]))'(t)== (𝔻^2) (Subscript[U, 0])(t) + 
              sin((Subscript[U, 0])(t)), U' (t)  ==  (Subscript[U, 1])(t)

• Since the derivatives with respect to time are explicit and can be solved for, it will be treated as an ODE: solve for U' (t) = (({{(Subscript[U, 0])' (t)}, {(Subscript[U, 1])' (t)}}))= (({{(Subscript[U, 1])(t)}, { (𝔻^2) (Subscript[U, 0])(t) + 
                      sin((Subscript[U, 0])(t))}}))

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• First, the problem is identified as a possible PDE by the presence of two independent variables.

• Next derivative orders are determined in each dimension.

• The method currently implemented is the numerical method of lines, where a (spatial) discretization is done in all but one independent (temporal) variable.  
   At this stage of the solution, a temporal variable is chosen.  Here the choice is fairly straight forward because one dimension (t) has initial conditions while
   the other (x) has boundary conditions.

• Next, the system is symbolically expressed as a system of one independent variable: ((Subscript[U, 0]))''(t)== (𝔻^2) (Subscript[U, 0])(t) + 
            sin((Subscript[U, 0])(t))
   (𝔻^2) represents the operator which approximates the second order x derivative.

• The system is converted to first order: ((Subscript[U, 1]))'(t)== (𝔻^2) (Subscript[U, 0])(t) + 
              sin((Subscript[U, 0])(t)), U' (t)  ==  (Subscript[U, 1])(t)

• Since the derivatives with respect to time are explicit and can be solved for, it will be treated as an ODE: solve for U' (t) = (({{(Subscript[U, 0])' (t)}, {(Subscript[U, 1])' (t)}}))= (({{(Subscript[U, 1])(t)}, { (𝔻^2) (Subscript[U, 0])(t) + 
                      sin((Subscript[U, 0])(t))}}))

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

• A grid spacing such the error estimate is within tolerance is determined using the initial condition.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

• A grid spacing such the error estimate is within tolerance is determined using the initial condition.

• For this spacing, the operator (𝔻^2) is finalized: often as a differentiation matrix.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

• A grid spacing such the error estimate is within tolerance is determined using the initial condition.

• For this spacing, the operator (𝔻^2) is finalized: often as a differentiation matrix.

• The boundary conditions are incorporated into the equation; in this case they are periodic, so they have already been included in (𝔻^2).

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

• A grid spacing such the error estimate is within tolerance is determined using the initial condition.

• For this spacing, the operator (𝔻^2) is finalized: often as a differentiation matrix.

• The boundary conditions are incorporated into the equation; in this case they are periodic, so they have already been included in (𝔻^2).

• The form of  (𝔻^2) and the contribution from the boundary conditions are used to determine the sparsity of the Jacobian, which will be computed with finite differences using a minimal number of function evaluations if it is needed by the ODE solver.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

• A grid spacing such the error estimate is within tolerance is determined using the initial condition.

• For this spacing, the operator (𝔻^2) is finalized: often as a differentiation matrix.

• The boundary conditions are incorporated into the equation; in this case they are periodic, so they have already been included in (𝔻^2).

• The form of  (𝔻^2) and the contribution from the boundary conditions are used to determine the sparsity of the Jacobian, which will be computed with finite differences using a minimal number of function evaluations if it is needed by the ODE solver.

• The system of ODEs initialized by the discretized initial condition is integrated in t.  The default solver automatically switches between a nonstiff and stiff solver as required by the problem.

Solving a PDE: choices to get to a solution.

NDSolve[{(((∂^2) u(t, 
                      x))/(∂t ∂t))==(((∂^2) u(t, 
                        x))/(∂x ∂x))+sin(u(t, x)),u(0, x) == (E^(-(x^2))),(((∂u(t, x))/(∂t))/.t -> 0)==0,u(t, -L) == u(t, L)},u,{t, 0, L},{x, -L, L}]

• ...

• The operator (𝔻^2) is computed in a symbolic form depending on grid spacing.

• A symbolic estimate of approximation error of (𝔻^2) is formed.  This is based on extrapolation between a grid and the one with twice as many points including the midpoints between the points of the first grid.

• A grid spacing such the error estimate is within tolerance is determined using the initial condition.

• For this spacing, the operator (𝔻^2) is finalized: often as a differentiation matrix.

• The boundary conditions are incorporated into the equation; in this case they are periodic, so they have already been included in (𝔻^2).

• The form of  (𝔻^2) and the contribution from the boundary conditions are used to determine the sparsity of the Jacobian, which will be computed with finite differences using a minimal number of function evaluations if it is needed by the ODE solver.

• The system of ODEs initialized by the discretized initial condition is integrated in t.  The default solver automatically switches between a nonstiff and stiff solver as required by the problem.

• The solution is formed as an InterpolatingFunction.

Summary

Mathematica's key technologies are brought together in a unique way by the common sharing of symbolic expressions.  Since everything is represented as a symbolic expression, interactivity between seemingly different program pieces usually just works.  The ability to reuse important base components in several ways allows us to build Mathematica as a more powerful system and allows you to use it to attack problems in a powerful way.