# "LocallyExact" Method for NDSolve

## Introduction

A differential system can sometimes be solved 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:

### 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:
The solution evolves on the unit circle:

### 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:

### 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":  The simplification is performed only once during the initialization phase that constructs the data object for the numerical integration method.

## Option Summary

 option name default value "SimplificationFunction" None function to use in simplifying the result of DSolve

Option of the method "LocallyExact".