此为 Mathematica 7 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.2)

Introduction to Numerical Differential Equations

NDSolve[eqns,y,{x,xmin,xmax}]
solve numerically for the function y, with the independent variable x in the range xmin to xmax
NDSolve[eqns,{y1,y2,...},{x,xmin,xmax}]
solve a system of equations for the yi

Numerical solution of differential equations.

This generates a numerical solution to the equation yPrime (x)=y (x) with 0<x<2. The result is given in terms of an InterpolatingFunction.
In[1]:=
Click for copyable input
Out[1]=
Here is the value of y (1.5).
In[2]:=
Click for copyable input
Out[2]=
With an algebraic equation such as x2+3x+1=0, each solution for x is simply a single number. For a differential equation, however, the solution is a function, rather than a single number. For example, in the equation yPrime (x)=y (x), you want to get an approximation to the function y (x) as the independent variable x varies over some range.
Mathematica represents numerical approximations to functions as InterpolatingFunction objects. These objects are functions which, when applied to a particular x, return the approximate value of y (x) at that point. The InterpolatingFunction effectively stores a table of values for y (xi), then interpolates this table to find an approximation to y (x) at the particular x you request.
y[x]/.solutionuse the list of rules for the function y to get values for y[x]
InterpolatingFunction[data][x]evaluate an interpolated function at the point x
Plot[Evaluate[y[x]/.solution],{x,xmin,xmax}]
plot the solution to a differential equation

Using results from NDSolve.

This solves a system of two coupled differential equations.
In[3]:=
Click for copyable input
Out[3]=
Here is the value of z[2] found from the solution.
In[4]:=
Click for copyable input
Out[4]=
Here is a plot of the solution for z[x] found on line 3. Plot is discussed in "Basic Plotting".
In[5]:=
Click for copyable input
Out[5]=
NDSolve[eqn,u,{x,xmin,xmax},{t,tmin,tmax},...]
solve a partial differential equation

Numerical solution of partial differential equations.