 Tutorials
 See Also

Related Guides
 Calculus
 Differential Equations
 Equation Solving
 Geometric Computation
 Solvers over Regions
 Life Sciences & Medicine: Data & Computation
 MeshBased Geometric Regions
 Numerical Evaluation & Precision
 Partial Differential Equations
 Scientific Models
 Summary of New Features in 10
 Systems Modeling
 New in 10.0: Geometry
 New in 10.0: Symbolic & Numeric Computation
NDSolve[eqns,u,{x,x_{min},x_{max}}]
finds a numerical solution to the ordinary differential equations eqns for the function u with the independent variable x in the range to .
NDSolve[eqns,u,{x,x_{min},x_{max}},{y,y_{min},y_{max}}]
solves the partial differential equations eqns over a rectangular region.
NDSolve[eqns,u,{x,y}∈Ω]
solves the partial differential equations eqns over the region Ω.
NDSolve[eqns,u,{t,t_{min},t_{max}},{x,y}∈Ω]
solves the timedependent partial differential equations eqns over the region Ω.
NDSolve[eqns,{u_{1},u_{2},…},…]
solves for the functions .
Details and OptionsDetails and Options
 NDSolve gives results in terms of InterpolatingFunction objects.
 NDSolve[eqns,u[x],{x,x_{min},x_{max}}] gives solutions for rather than for the function u itself.
 Differential equations must be stated in terms of derivatives such as , obtained with D, not total derivatives obtained with Dt.
 Partial differential equations may also be specified using the differential operators Grad (), Div (), Laplacian (), and Curl (). Typically these operators are used as in Inactive[op] to keep the operator form from evaluating.
 NDSolve solves a wide range of ordinary differential equations as well as many partial differential equations.
 NDSolve can also solve many delay differential equations.
 In ordinary differential equations, the functions must depend only on the single variable t. In partial differential equations, they may depend on more than one variable.
 WhenEvent[event,action] may be included in the equations eqns to specify an action that occurs when event becomes True.
 The differential equations must contain enough initial or boundary conditions to determine the solutions for the completely.
 Initial and boundary conditions are typically stated in the form , , etc., but may consist of more complicated equations.
 The , , etc. can be lists, specifying that is a function with vector or general list values.
 Periodic boundary conditions can be specified using .
 The point that appears in the initial or boundary conditions need not lie in the range to over which the solution is sought.
 Boundary values may also be specified using DirichletCondition and NeumannValue.
 In delay differential equations, initial history functions are given in the form , where is in general a function of x.
 The differential equations in NDSolve can involve complex numbers.
 NDSolve can solve many differential‐algebraic equations, in which some of the eqns are purely algebraic, or some of the variables are implicitly algebraic.
 The can be functions of the dependent variables and need not include all such variables.
 The following options can be given:

AccuracyGoal Automatic digits of absolute accuracy sought Compiled Automatic whether expressions should be compiled automatically DependentVariables Automatic the list of all dependent variables EvaluationMonitor None expression to evaluate whenever the function is evaluated InterpolationOrder Automatic the continuity degree of the final output MaxStepFraction 1/10 maximum fraction of range to cover in each step MaxSteps Automatic maximum number of steps to take MaxStepSize Automatic maximum size of each step Method Automatic method to use NormFunction Automatic the norm to use for error estimation PrecisionGoal Automatic digits of precision sought StartingStepSize Automatic initial step size used StepMonitor None expression to evaluate when a step is taken WorkingPrecision MachinePrecision precision to use in internal computations  NDSolve adapts its step size so that the estimated error in the solution is just within the tolerances specified by PrecisionGoal and AccuracyGoal.
 The option NormFunction>f specifies that the estimated errors for each of the should be combined using .
 AccuracyGoal effectively specifies the absolute local error allowed at each step in finding a solution, while PrecisionGoal specifies the relative local error.
 If solutions must be followed accurately when their values are close to zero, AccuracyGoal should be set larger, or to Infinity.
 The default setting of Automatic for AccuracyGoal and PrecisionGoal is equivalent to WorkingPrecision/2.
 The default setting of Automatic for MaxSteps estimates the maximum number of steps to be taken by NDSolve, depending on start and stop time and an estimate of the step size. Should this not be possible, a fixed number of steps is taken.
 The setting for MaxStepFraction specifies the maximum step to be taken by NDSolve as a fraction of the range of values for each independent variable.
 With DependentVariables>Automatic, NDSolve attempts to determine the dependent variables by analyzing the equations given.
 NDSolve typically solves differential equations by going through several different stages, depending on the type of equations. With Method>{s_{1}>m_{1},s_{2}>m_{2},…}, stage is handled by method . The actual stages used and their order are determined by NDSolve, based on the problem to solve.
 Possible solution stages are:

"TimeIntegration" time integration for systems of differential equations "BoundaryValues" ordinary differential equation boundary value solutions "DiscontinuityProcessing" symbolic processing for handling of discontinuous differential equations "EquationSimplification" simplification of equation form for numerical evaluation "IndexReduction" symbolic index reduction for differential algebraic equations "DAEInitialization" consistent initialization for differential algebraic equations "PDEDiscretization" discretization for partial differential equations  With Method>m_{1} or Method>{m_{1},s_{2}>m_{2},…}, the method is assumed to be for time integration, so Method>m_{1} is equivalent to Method>{"TimeIntegration">m_{1}}.
 Possible explicit time integration settings for the Method option include:

"Adams" predictor‐corrector Adams method with orders 1 through 12 "BDF" implicit backward differentiation formulas with orders 1 through 5 "ExplicitRungeKutta" adaptive embedded pairs of 2(1) through 9(8) Runge–Kutta methods "ImplicitRungeKutta" families of arbitrary‐order implicit Runge–Kutta methods "SymplecticPartitionedRungeKutta"interleaved Runge–Kutta methods for separable Hamiltonian systems  With Method>{"controller",Method>"submethod"} or Method>{"controller",Method>{m_{1},m_{2},…}}, possible controller methods include:

"Composition" compose a list of submethods "DoubleStep" adapt step size by the double‐step method "EventLocator" respond to specified events "Extrapolation" adapt order and step size using polynomial extrapolation "FixedStep" use a constant step size "OrthogonalProjection" project solutions to fulfill orthogonal constraints "Projection" project solutions to fulfill general constraints "Splitting" split equations and use different submethods "StiffnessSwitching" switch from explicit to implicit methods if stiffness is detected  Methods used mainly as submethods include:

"ExplicitEuler" forward Euler method "ExplicitMidpoint" midpoint rule method "ExplicitModifiedMidpoint" midpoint rule method with Gragg smoothing "LinearlyImplicitEuler" linearly implicit Euler method "LinearlyImplicitMidpoint" linearly implicit midpoint rule method "LinearlyImplicitModifiedMidpoint"linearly implicit Bader‐smoothed midpoint rule method "LocallyExact" numerical approximation to locally exact symbolic solution  The setting InterpolationOrder>All specifies that NDSolve should generate solutions that use interpolation of the same order as the underlying method used. »
ExamplesExamplesopen allclose all
Basic Examples (4)Basic Examples (4)
Solve a firstorder ordinary differential equation:
In[1]:= 
Out[1]= 
In[2]:= 
Out[2]= 
Use the function and its derivative in a plot:
In[3]:= 
Out[3]= 
In[4]:= 
Out[4]= 
Secondorder nonlinear ordinary differential equation:
In[1]:= 
Out[1]= 
Plot the function and its first two derivatives:
In[2]:= 
Out[2]= 
System of ordinary differential equations:
In[1]:= 
Out[1]= 
In[2]:= 
Out[2]= 
This solves the heat equation in one dimension:
In[1]:= 
Out[1]= 
In[2]:= 
Out[2]= 
In[3]:= 
Out[3]= 
Related GuidesRelated Guides
 Calculus
 Differential Equations
 Equation Solving
 Geometric Computation
 Solvers over Regions
 Life Sciences & Medicine: Data & Computation
 MeshBased Geometric Regions
 Numerical Evaluation & Precision
 Partial Differential Equations
 Scientific Models
 Summary of New Features in 10
 Systems Modeling
 New in 10.0: Geometry
 New in 10.0: Symbolic & Numeric Computation