Documentation
Mathematica
Built-in Functions
Numerical Computation
Equation Solving
NDSolve
LocallyExact
Introduction
The solution of a differential system can sometimes be solvable by analytic means. The function DSolve implements many of the known algorithmic techniques.
However, differential systems that can be solved in closed form constitute only a small subset. Despite this fact, when a closed-form solution does not exist for the entire vector field, it is often possible to analytically solve a system of differential equations for part of the vector field. An example of this is the method Splitting, which breaks up a vector field
into subfields
such that
.
The idea underlying the method LocallyExact is that rather than using a standard numerical integration scheme, when a solution can be found by DSolve, direct numerical evaluation can be used to locally advance the solution.
Since the method LocallyExact makes no attempt to adaptively adjust step sizes, it is primarily intended for use as a submethod between integration steps.
Examples
Load a package with some predefined problems.
In[1]:=
Harmonic oscillator
Numerically solve the equations of motion for a harmonic oscillator using the method LocallyExact. The result is two interpolating functions that approximate the solution and the first derivative.
In[75]:=
Out[78]=
The solution evolves on the unit circle.
In[56]:=

Global versus local
The method LocallyExact is not intended as a substitute for a closed-form (global) solution.
Despite the fact that the method LocallyExact uses the analytic solution to advance the solution, it only produces solutions at the grid points in the numerical integration (or even inside grid points if called appropriately). Therefore, there can be errors due to sampling at interpolation points that do not lie exactly on the numerical integration grid.
Plot the error in the first solution component of the harmonic oscillator and compare it with the exact flow.
In[57]:=

Simplification
The method LocallyExact has an option SimplificationFunction that can be used to simplify the results of DSolve.
Here is the linearized component of the differential system that turns up in the splitting of the Lorenz equations using standard values for the parameters.
In[91]:=
This subsystem is exactly solvable by DSolve.
In[97]:=
Out[97]=
Often the results of DSolve can be simplified. This defines a function to simplify an expression and also prints out the input and the result.
In[109]:=
The function can be passed as an option to the method LocallyExact.
In[110]:=


Out[110]=
The simplification is performed only once during the initialization phase that constructs the data object for the numerical integration method.
Option summary

Options of the method LocallyExact.