Difference between revisions of "Maple/Spring 2024 Startup"

From PrattWiki
Jump to navigation Jump to search
(Created page with "This document is meant to take you step-by-step through getting access to Maple and using it to solve problems involving Laplace Transforms and Inverse Laplace Transforms. ==...")
 
 
Line 1: Line 1:
This document is meant to take you step-by-step through getting access to Maple and using it to solve problems involving Laplace Transforms and Inverse Laplace Transforms.
+
This document is meant to take you step-by-step through using Maple to solve problems involving Laplace Transforms and Inverse Laplace Transforms.
 
 
== Accessing Maple ==
 
For Spring 2023, the best way to access Maple is through a Duke Container.  The following information comes from [[Maple#Duke_Container]].
 
 
 
Duke has a suite of Containers for Virtual Software, and among them is a container for Maple.  The container is a Linux-based web-accessible application that includes a file system, web browser, and Maple.  The positives are that it is free for Duke students and very easy to access and use; the negative is that the file system doesn't really connect to any other file system at Duke.  Fortunately, the presence of a browser ameliorates that issue.
 
 
 
To get access to the Virtual Computing Manager, go to [https://vcm.duke.edu/ VCM] and log in with your Duke credentials.  * To access the Maple container, go to the "Reserve a Container" link below the "Virtual Software" section of the landing page. 
 
* Once there, if have previously reserved a Maple container, it will show up on the left; if you haven't reserved a Maple container before, scroll to the Maple container in the "Reservations available" section. 
 
* Once reserved, you can go to the VCM site and it will already be there.  Click on the '''Maple''' link under '''CONTAINERS''' in '''My reservations'''
 
* You will need to '''Login''' to the container using the blue button in the '''CONTAINER CONTROLS''' section, at which point you will see a Linux session in a web page.  It may say "No session for pid ##" - click OK there.  You should now see icons for Firefox web Browser and Maple 2019.
 
* Go ahead and start Maple by double-clicking the icon. 
 
** If it asks you if you want to update, you do not
 
** If it tells you "Invalid or missing license file" - that may mean that you were the first person to try to use Maple that day - congratulations!  To make things work:
 
*** Click '''Exit Maple'''
 
*** Close the browser with the container in it
 
*** Go back to the [https://vcm.duke.edu/ VCM] page, then the '''Reserve a Container''' page, then click the Maple container link
 
*** Click the '''Login''' button and then '''OK''' when "No session for pid ##" comes up
 
*** Double-click the Maple icon
 
*** Feel more confident after going through this process that computers are not quite ready to take over the world...
 
 
 
=== Files ===
 
The files that you create in the Container will live in the Container's file system - this is separate from your computer or Box or any other storage and there's no great way to connect things.  If you need to move files back and forth from outside the VCM, I highly recommend using a Box drive.  In the VCM, you can open Firefox and go to box.duke.edu to access and download files in your Box folder.  You can also upload items from your VCM drive to Box for access outside of the container.
 
 
 
The files will stay on the container for as long as the reservation lasts (the semester) but you will definitely want to back them up on Box.  The files will be in a folder called <code>/home/ubuntu/</code>.  When you save Maple files, you will have the option of creating a new folder - there is an icon near the top right of the "Save" or "Save As" window that looks like a file folder - you can use that to create a folder to organize your materials.
 
  
 
== Using Maple ==
 
== Using Maple ==
For Lab 10 in Spring 2023, there are some specific commands you will need to understand to get work done.  They are:
 
=== Restarting the worksheet ===
 
Whenever you make a change in a Maple worksheet, that change does '''not''' automatically propagate to the rest of the worksheet.  As a result, you may need to re-run the entire worksheet by hitting the !!! button.  In order to make sure the worksheet starts from scratch each time, you should put the <code>restart</code> at the top.
 
 
=== Adding the inttrans functions ===
 
=== Adding the inttrans functions ===
 
Maple does not automatically know how to do Laplace or inverse Laplace transforms - those commands are in a module called <code>inttrans</code> and the way you will load that module into Maple is with the command <code>with(inttrans)</code>.  If you do not need to see the results of loading the module, you can put a : at the end of the line, which tells Maple to suppress the output (i.e. <code>with(inttrans):</code>).
 
Maple does not automatically know how to do Laplace or inverse Laplace transforms - those commands are in a module called <code>inttrans</code> and the way you will load that module into Maple is with the command <code>with(inttrans)</code>.  If you do not need to see the results of loading the module, you can put a : at the end of the line, which tells Maple to suppress the output (i.e. <code>with(inttrans):</code>).

Latest revision as of 15:49, 2 April 2024

This document is meant to take you step-by-step through using Maple to solve problems involving Laplace Transforms and Inverse Laplace Transforms.

Using Maple

Adding the inttrans functions

Maple does not automatically know how to do Laplace or inverse Laplace transforms - those commands are in a module called inttrans and the way you will load that module into Maple is with the command with(inttrans). If you do not need to see the results of loading the module, you can put a : at the end of the line, which tells Maple to suppress the output (i.e. with(inttrans):).

Helping Maple understand step functions

Generally, Maple leaves Heaviside(0) as undefined; that can get unwieldy later, so teaching Maple to assign that a value can be helpful. We will go ahead and teach Malpe that Heaviside(0)=1, which is consistent with discrete time step functions. The command to do that is:

with(inttrans)

Useful Maple commands for work with Laplace Transforms

The page at Maple/Laplace Transforms goes into detail about some help functions, and then summarizes them at Maple/Laplace_Transforms#Typical_Starting_Commands_When_Working_With_Laplace.

Defining functions

The easiest way to define a function in Maple is:

FUN_NAME := function

If you want to explicitly note what a function is a function of, or you want to be able to call it with explicit arguments later, you can use:

FUN_NAME := (IN1, IN2, ...) -> function

For Lab 10, you will not need to use the latter form except in the useful Maple commands already given above.

Making numerical substitutions

Before taking Laplace or inverse Laplace transforms, you may need to replace symbols with numbers. The easiest way to do this is with the subs command. The subs command will be a sequence of equalities for the substitutions followed by the item into which substitutions are made. The substitutions are only made in the last item! Here are two examples - one with all the substitutions done in a single command, and one where a list of equations is defined and then used:

Hn := subs(R = 10000., C = 0.000100, SCS(H, s))

or

MyVals := R = 10000., C = 0.000100
Hn := subs(MyVals, SCS(H, s))

Note that in each the "SCS" or "Simplify / Collect / Sort" command is used to make the transfer function look better.

Taking Laplace transforms

Easy as:

laplace(function, t, s)

Taking Inverse Laplace transforms

Easy as:

invlaplace(function, s, t)

though there are two helper versions of the inverse to look at. The function IL is defined to do partial fraction expansion before taking the inverse, which sometimes results in a cleaner answer. This command only works if the transform is a ratio of polynomials of s and does not include exponentials in s (either because of time shifts or being right-sided periodic). Given that, for transforms that are ratios of polynomials, you can use

IL(function, s, t)

and for transforms that involve time shifts, you can use

ILTS(function, s, t)

Plotting results

If you have a variable that is an implied function of $$t$$, you can make a plot by giving the plot command the function and a range for t. Here are examples of plotting a single item and plotting two items:

  • Single item with axis labels and title:
plot(h*u(t), t = -1 .. 5, labeldirections = [horizontal, vertical], labels = ["Time (s)", "Voltage (V)"], title = "Impulse Response")
  • Two items with legend, axis labels, title, and specific colors:
plot([u(t), sr*u(t)], t = -1 .. 5, legend = ["input", "output"], labeldirections = [horizontal, vertical], labels = ["Time (s)", "Voltage (V)"], color = [black, red], title = "Step Response")

Submitting your Files

The easiest way to submit your files (PDF or MW) will be to use the Firefox browser in the container, log in to Gradescope, and upload things there.