# Mathematica Tutorial Beginner - University Of Washington

1y ago
62 Views
213.29 KB
9 Pages
Last View : 1m ago
Transcription

Christopher LumAutonomous Flight Systems LaboratoryUpdated: 12/09/05Beginner’s Mathematica TutorialIntroductionThis document is designed to act as a tutorial for an individual who has had no priorexperience with Mathematica. For a more advanced tutorial, walk through theMathematica built in tutorial located at Help Tutorial on the Mathematica Task Bar.For any questions or concerns, please contactChristopher Lumlum@u.washington.eduStarting the Program1. Start Mathematica. After the program starts, you should see something similar tothat shown in Figure 1.Figure 1: Basic Mathematica interface2. It is possible that the Basic Input Palette is not visible at startup. To activate thiswindow, go File Palettes Basic Input Christopher W. Lumlum@u.washington.eduPage 1/9

Using Mathematica1. Mathematica is a symbolic manipulator. To assign a variable, simply type it inthe Input Window. The enter in the command, you need to hit “Shift Enter”.1. Type in “x 1” then hit “Shift Enter”2. Type in “y a b;” then hit “Shift Enter”3. Type “z x y” then hit “Shift Enter”(note the semicolon here!)Figure 2: Entering in variables into MathematicaAs can be seen, the semi-colon suppresses the outputs to the screen. Also noticethat a and b do not need to be defined as numerical values.2. Mathematica is nice because it can be used to compose documents which havetext and code interlaced with each other. To add a line of text, first type in theline. Notice that this is in bold font just like the rest of the commands. Alsonotice the blue braces that appear to the right of the Input window (see Figure 2).Click on this brace to select it. Then select Format Style Text on the Task Baror simply hit “Alt 7”.3. Mathematica stores variables until they are explicitly cleared or you quit thekernel. Therefore, it is good practice to clear variables when they are no longerneeded. To do this, we use the Clear function. Clear the variables x, y, and z. Christopher W. Lumlum@u.washington.eduPage 2/9

Functions: ClearNote:All Mathematica functions begin with a capital letter and theirarguments are enclosed in square braces. For example to clear x,y, and z, we need to typeClear[x,y,z]Remember that you need to hit “Shift Enter” to execute thecommand.4. Recall that the state space representation of the mass/spring/damper system isgiven byx& Ax BuEquation 1y Cx Du1 0 where A k / m c / m 0 B 1 / m C (1 0 )D 0For this situation, let k 2, c 0.5, and m 1. Enter in these constants intoMathematica now. A sample code is shown below.Notice here that c is entered as ½, not 0.5. This is important in Mathematicabecause there is no numerical round off when using fractions.5. Now define the A, B, C, and D matrices. Note: You cannot assign a value/objectto the letter “C” because this is a protected Mathematica symbol. Therefore, use adifferent name for the matrices.To enter a matrix, click on the Matrix Button as shown in Figure 2. Thisgenerates a blank 2x2 matrix to be filled in. To add rows, select where you wouldlike to insert a row and press “Ctrl Enter”. To add columns, select where youwould like to insert a column and press “Ctrl ,” A sample code is shown below. Christopher W. Lumlum@u.washington.eduPage 3/9

6. To check the internal stability of the system, calculate the eigenvalues and of theA matrix. Also obtain the eigenvectors. You may want to use the Simplifyfunction to simplify the expressions.Functions: Eigenvalues, Eigenvectors, SimplifyNote:Greek symbols can be inserted using the Basic Input Palette of byusing the Esc, letter, Esc key combination. For example to quicklyinsert the λ symbol. Type “Esc, l, Esc”. A sample code is shownbelow. Christopher W. Lumlum@u.washington.eduPage 4/9

7. Verify that the eigenvectors and eigenvalues obtained satisfy the definition( A λi I )vi 0Equation 2Functions: IdentityMatrix,Note:Mathematica may give a number which appears to not be zero.Once again, just use the Simplify function to simplify theexpression.8. Calculate the characteristic equation for this system, p(λ). Recall that thecharacteristic equation is given by Christopher W. Lumlum@u.washington.eduPage 5/9

p ( λ ) det ( λ I A ) 0Equation 3This is a function of λ. It is simple to define your own function in Mathematica.For example, Equation 3 can easily be defined using the commandNotice the λ . This defines that the function p is a function with λ as itsargument. Multiple arguments would be separated by commas.Functions: DetNote:None9. Verify that the eigenvalues obtain in part 6 are roots of the characteristic equation.A sample code is shown belowFunctions None:Note:10. Calculate the transfer function between x1 and y. Recall that this is given byG (s) Functions:Note:y (s) 1 C ( sI A ) B Du (s)Equation 4InverseA sample code is shown below Christopher W. Lumlum@u.washington.eduPage 6/9

11. Now calculate the response of the system to a unit step input in the Laplacedomain. Recall that the in the Laplace domain, a step input is u ( s ) 1/ s .After you have the response in the Laplace domain, use the inverse Laplacetransform to calculate the response in the time domain.Functions InverseLaplaceTransform:Note:A sample code is shown below12. Plot the response of the system in the time domain over the range 0 t 10seconds. Christopher W. Lumlum@u.washington.eduPage 7/9

In addition, import the response of the system that was calculated usingMatlab/Simulink. You should have created this figure during the SimulinkTutorial and saved it as a .jpg. To import a jpg into Mathematica, select Edit Insert Object Microsoft Word Picture. Microsoft Word should open. Simplyinsert the picture into the box and then close Microsoft Word.Functions:Note:PlotA sample code is shown below Christopher W. Lumlum@u.washington.eduPage 8/9

Version History:09/29/04: Created:11/23/05: Updated:12/01/05: Updated:12/09/05: Updated: Christopher W. LumMade this format match other to-do documentsand removed references to AA547.Changed headers to match how-to templateMade changes to layout and added footer.lum@u.washington.eduPage 9/9

Dec 09, 2005 · Beginner’s Mathematica Tutorial Introduction This document is designed to act as a tutorial for an individual who has had no prior experience with Mathematica. For a more advanced tutorial, walk through the Mathematica built in tutorial located at Help Tutorial on the Mathematica Task Bar.

Related Documents:

1 Mathematica Basics This chapter is an introduction to Mathematica.We briefly describe many of the most important and basic elements of Mathematica and discuss a few of the more common technical issues related to using Mathematica.Since our primary goal is to use Mathematica to help us understand calculus, you should not initially spend a great amount of time pouring

Online Help from Mathematica 2 Mathematica Tutorial.nb. Introduction Mathematica is a system for doing mathematics on the computer.It can do numerics,symbolics,graphics and is also a programming language.Mathematica has infinite precision.It can plot functions of a single variable; make

mathematica Remarks This section provides an overview of what wolfram-mathematica is, and why a developer might want to use it. It should also mention any large subjects within wolfram-mathematica, and link out to the related topics. Since the Documentation for wolfram-mathematica is new, you may need to create initial versions of those related .

PROGRAMMING IN MATHEMATICA, A PROBLEM-CENTRED APPROACH 7 1.3. Algebraic computations. One of the abilities of Mathematica is to handle symbolic com-putations. Consider the expression (x 1)2. One can use Mathematica to expand this expression: Expand[(x 1) 2] 1 2x x2 Mathematica can also do the inverse of this task, namely to factorize an expression:

Start up Mathematica from a Linux desktop terminal window. Parallel Mathematica jobs can be submitted from with the Mathematica notebook interface as well as using PBS command ﬁles and the example scripts show how to setup and submit the jobs Documentation:Submitting Mathematica Parallel Jobs (UVACSE) October 8, 2014 44 / 46

Mathematica. It does not assume any prior knowledge of advanced data analysis or statistical techniques. Familiarity with a programming language may prove to be useful, but it is not essential. For beginners in Mathematica, Chapter 2, Dissecting Data Using Mathematica, provides a short primer on the essentials of Mathematica programming.

1.4 Getting Help, Interrupting Mathematica Mathematica has an excellent help tool. For example, to nd a Mathematica function to solve the system of equations x2 3y2 36; 2x y 3, from the Help menu choose the Function Navigator, then Mathematics and Algorithms and then Equation Solving. Try one of the functions and see which one is .

in advanced mathematics used in US universities are also popular in Australian universities for students studying engineering and some areas of applied sciences. However, the advanced mathematics .