Solve Example 1.9.2 using the Mathematica program.
The Mathematica program uses an iterative method to compute the solution and accepts the second-order form of the equation of motion. The text after the prompt \boxed{\textsf{In[1]:=}} is typed by the user and returns the solution stored in the variable \boxed{\textsf{x[t]}}. Mathematica has several equal signs for different purposes. In the argument of the NDSolve function, the user types in the differential equation to be solved, followed by the initial conditions, the name of the variable (response), and the name of the independent variable followed by the interval over which the solution is sought. NDSolve computes the solution and stores it as an interpolating function; hence the code returns the plot following the output prompt \boxed{\textsf{Out[1]=}}. The plot command requires the name of the interpolating function returned by NDSolve, \boxed{\textsf{x[t]}} in this case, the independent variable, \boxed{\textsf{t}}, and the range of values for the independent variable.
In[1]:= NDSolve[{x”[t]+(1/3)*x'[t]+(2/3)*x[t]==0,x'[0]==0.25,x[0]==0}, x,{t,0,20}]; Plot[Evaluate[x[t]/.%],{t,0,20}] Out[1]={{x–>InterpolatingFunction[{{0.,20.}},<>]}} Out[2]= |