PHYSICS 2235
Lab 6
Exercises
Assignment
In today's lab, we introduce the Maple mathematical software package.
Exercise 1.
Start a Maple session by typing xmaple & at the UNIX prompt. Click on the New Worksheet icon to obtain a Maple prompt.
Maple help is accessible by typing ? at the Maple prompt. You can also find information about specific commands by typing
> ?[command]
at the Maple prompt. (A new window will pop up.)
Also, the Online Help at the Maplesoft.com webpage shows more examples than we could ever hope to cover in this course.
Note that there are two command line input modes, "Text" input and "2D Math" input. You can toggle between these modes using the F5 key, or the toolbar buttons. If you select some input that you have written in Text mode, by selecting that code with the mouse and right clicking, you can convert it to 2D math. You might want to experiment with these modes in the following exercises; See which you prefer.
There is a Maple Tour for new users, accessible through the "Help" pulldown menu. You might also try clicking on the Getting Started icon on the start page.
Using the the ? utility, see if you can figure out how to perform the following:
- Find the roots of a quadratic polynomial, e.g.
16x^{2} + 37x - 7 = 0
using the solve command. Note that, by default, Maple will give you the most accurate answer it can, e.g. by expressing numbers as fractions rather than truncated decimal numbers. Try using the evalf command to put numbers in decimal format.
- Evaluate the infinite series 4*(1 - 1/3 + 1/5 - 1/7 + 1/9 - ...) using sum.
- Find the value of the definite integral of sin^{2}x from 0 to 5.
- Find the first and second derivatives of g(x) = 13x^{2} -25x^{4} = 0 using diff.
- Use dsolve to solve the differential equation for the harmonic oscillator
m(d^{2}x(t)/dt^{2}) + kx(t) = 0
If the initial conditions are y(0) = 0 and dy(0)/dt = 1, evaluate the constants of integration (also using dsolve).
- Save and Export your working file to various output forms, including Maple Worksheet (.mw), plain text (.txt), and portable document format (.pdf).
Exercise 2.
Some more introductory Maple Exercises, emphasizing plotting.
- plot sin^{2}(x) versus x for values of x from 0 to 4π.
- Plot cos(t), cos(2t) and cos(3t) from t=0 to 2*Pi on the same graph. Right-click on the plot you have produced and export it as a Portable Network Graphics (.png) file (e.g. for inclusion in a document).
- Plot the sum of the first N=5 terms of the Fourier Series for a square wave, on the interval from t=0 to 4*Pi.
f(x) = 1/2 -2/Pi*sum(n=1 to n=N, n odd) sin(nx)/n
(You may want to refresh your memory on the sum command syntax from Exercise 1.) What happens if you vary N? Are any limitations of the Fourier Series apparent?
- Use the := symbol to define the potential for the two-dimensional harmonic oscillator:
Then define k_{x} and k_{y} to have some particular numerical values. (Can you figure out how to do subscripts?) Plot Φ(x,y) using the Maple plot3d command.
For fun, try grabbing the 3d plot with your cursor by left-clicking on it. What happens?
Assignment a06, due by noon Monday October 1
Problem 1.
An anharmonic oscillator obeys the differential equation:
In a Maple worksheet titled anharmonic.mw, perform the following:
- Find a general solution to the anharmonic oscillator equation.
- Find a particular solution to satisfy the initial conditions x(0) = 10, dx(0)/dt = 0
- Plot the particular solution, on the same graph as the solution to the simple harmonic oscillator equation
satisfying the same initial conditions. The graph should extend from t = 0 to t = 4π.
Export your worksheet as a Maple text file anharmonic.txt.
Submit your worksheet anharmonic.mw and your text file anharmonic.txt.
Back to main Physics 2235 page