Load a package with some pre-defined problems.
Harmonic oscillator
Numerically solve the equations of motion for a harmonic oscillator using the method LocallyExact. The result is two interpolating functions which approximate the solution and the first derivative.
The solution evolves on the unit circle.
Global vs 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 gridpoints 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.
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.
This subsystem is exactly solvable by DSolve.
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.
The function can be passed as an option to the method LocallyExact.
"Before simplification "{12402((1201 ⅇ12 (-11-1201) T+9 1201 ⅇ12 (-11-1201) T+1201 ⅇ12 (-11+1201) T-9 1201 ⅇ12 (-11+1201) T) Y1[T])-10 (ⅇ12 (-11-1201) T-ⅇ12 (-11+1201) T) Y2[T]1201,-28 (ⅇ12 (-11-1201) T-ⅇ12 (-11+1201) T) Y1[T]1201+12402((1201 ⅇ12 (-11-1201) T-9 1201 ⅇ12 (-11-1201) T+1201 ⅇ12 (-11+1201) T+9 1201 ⅇ12 (-11+1201) T) Y2[T]),ⅇ-8 T/3 Y3[T]}
"After simplification "{11201(ⅇ-11 T/2 (1201 Cosh[1201 T2] Y1[T]+1201 Sinh[1201 T2] (-9 Y1[T]+20 Y2[T]))),ⅇ-11 T/2 Cosh[1201 T2] Y2[T]+ⅇ-11 T/2 Sinh[1201 T2] (56 Y1[T]+9 Y2[T])1201,ⅇ-8 T/3 Y3[T]}
The simplification is performed only once during the initialization phase that constructs the data object for the numerical integration method.