2 writing data to a file 281 when you read the le

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: > with(plots, odeplot): > odeplot( sol3, [t, y(t)], 0..4 ); 7 6 y5 4 3 0 1 2 t 3 4 The DEtools package contains commands that can help you investigate, manipulate, plot, and solve differential equations. For details, refer to the ?DEtools help page. Interactive ODE Analyzer The dsolve[interactive](odesys,options) command launches a graphical user interface for the investigation and solution of ODE and ODE systems. 270 • Chapter 7: Solving Calculus Problems If odesys is not given in the call to dsolve[interactive], then odesys can be entered by using the interface; otherwise, the input equations are examined and used as a starting point for the application (these equations can be changed from within the graphical user interface). For details about the command and interface, see ?dsolve,interactive and ?worksheet,interactive,dsolveinterface. 7.3 Partial Differential Equations Partial differential equations (PDEs) are in general very difficult to solve. Maple provides a number of commands for solving, manipulating, and plotting PDEs. Some of these commands are in the standard library, but most of them reside in the PDEtools package. The pdsolve Command The pdsolve command can solve many partial differential equations. This is the basic syntax of the pdsolve command. pdsolve( pde, var ) • pde is the partial differential equation • var is the variable with respect to which pdsolve solves The following is the one-dimensional wave equation. > wave := diff(u(x,t), t,t) - c^2 * diff(u(x,t), x,x); wave := ( ∂2 ∂2 u(x, t)) − c2 ( 2 u(x, t)) ∂t2 ∂x To solve for u(x,t), first load the PDEtools package. > with(PDEtools): > sol := pdsolve( wave, u(x,t) ); sol := u(x, t) = _F1(c t + x) + _F2(c t − x) Note the solution is in terms of two arbitrary functions, _F1 and _F2. To plot the solution you need a particular set of functions. 7.3 Partial Differential Equations > f1 := xi -> exp(-xi^2); • 271 f1 := ξ → e(−ξ 2) > f2 := xi -> piecewise(-1/2<xi and xi<1/2, 1, 0); f2 := ξ → piecewise( −1 1 < ξ and ξ < , 1, 0) 2 2 Substitute these functions into the solution. > eval( sol, {_F1=f1, _F2=f2, c=1} ); u(x, t) = e(−(t+x) ) + 2 1 1 1 −t + x < and t − x < 2 2 0 otherwise Use the rhs command to select the solution. > rhs(%); e(−(t+x) ) + 2 1 1 1 −t + x < and t − x < 2 2 0 otherwise The unapply command converts the expression to a function. > f := unapply(%, x,t); f := (x, t) → e(−(t+x) ) + piecewise(−t + x < Plot the solution. > plot3d( f, -8..8, 0..5, grid=[40,40] ); 2 1 1 and t − x < , 1, 0) 2 2 272 • Chapter 7: Solving Calculus Problems Changing the Dependent Variable in a PDE The following is the one-dimensional heat equation. > heat := diff(u(x,t),t) - k*diff(u(x,t), x,x) = 0; heat := ( ∂2 ∂ u(x, t)) − k ( 2 u(x, t)) = 0 ∂t ∂x Try to find a solution of the form X (x)T (t) to this equation. Use the aptly named HINT option of pdsolve to suggest a cou...
View Full Document

This note was uploaded on 08/27/2012 for the course MATH 1100 taught by Professor Nil during the Spring '12 term at National University of Singapore.

Ask a homework question - tutors are online