How to | Solve a Partial Differential Equation
The Wolfram Language's differential equation solving functions can be applied to many different classes of differential equations, automatically selecting the appropriate algorithms without the need for preprocessing by the user. One such class is partial differential equations (PDEs).
Using D to take derivatives, this sets up the transport equation, , and stores it as pde:
Use DSolve to solve the equation and store the solution as soln. The first argument to DSolve is an equation, the second argument is the function to solve for, and the third argument is a list of the independent variables:
The answer is given as a rule and C is an arbitrary function.
You can also add an initial condition like by making the first argument to DSolve a list. The solution is stored as sol:
Use Plot3D to plot the solution:
Use DSolve with the inhomogeneous PDE with the initial condition :
Now, use Plot3D to plot the solution:
Use DSolve to solve a inhomogeneous PDE, for example, with the initial condition . The solution is stored as pdesol:
Use Manipulate to show how the solution Fsol changes with respect to the parameters a, b, and c:
The examples so far use DSolve to obtain symbolic solutions to PDEs. When a given PDE does not contain parameters, NDSolve can be used to obtain numerical solutions. The results of NDSolve are given as InterpolatingFunction objects.
Here, the solution produced by NDSolve is stored as nsol1:
Plot the solution with Plot3D:
The InterpolatingFunction object can be evaluated, plotted, and used in other operations.
Get just the InterpolatingFunction solution from nsol1 and assign it to the new symbol nsol2:
Plot the solution nsol2 with Plot3D:
Use ?NumericQ to prevent the function fsol from evaluating for non-numeric values of the parameter: