Lecture 15: Introduction to Mathematica

advertisement
EGR 231 Engineering Statics
Lecture A: Installing and Using Mathematica
Spring 2014
Today and Next Class Period:
Instructions to install Mathematica
Working through a Mathematica Tutorial
Homework: complete the Mathematica Tutorial and the attached problem sheet
After today’s class you should
-- have installed the math application software, Mathematica on your computer.
-- you should have some idea about the capability of Mathematica
-- understand some of the basic syntax for interacting with Mathematica
---------------------------------------------------------------------------------------------------Mathematica is a computational software program used in scientific,
engineering, and mathematical fields and other areas of technical computing.
It was originally conceived by Stephen Wolfram and is developed by
Wolfram Research of Champaign, Illinois.—Wikopedia, 2010
The types of things that you might use this software for in your engineering classes include:
a) make plots of functions
e) find derivatives
b) solve sets of linear equations
f) integrate
c) find roots
g) solve and/or simulate differential equations
d) simplify mathematical expression
f) curve fit
d) solve nonlinear equations
While you may use Mathematica to help you as a “mathematical calculator” tool, this tool will
generally not be available to you during exams and testing. So while you are encouraged to learn
its use, you may still have to perform the mathematics without this neat little tool.
Installing Mathematica:
Installation instructions for Mathematica can be found under the Loras Network Distribution
folder. Make your way to this network location by:
If using Windows 7.0:
Click the Windows Start button
and type \\ldsk01 in the Run box.
If using Windows 8.0:
Hold down the Windows Key and hit R to
bring up the Run Box. Type in \\ldsk01
in the Run box and hit Enter.
+
RR
In the Distribution folder, navigate to
\\ldsk01\Distribution\Mathematica\Mathematica8\Students
To install Mathematics can open the ST_Activation_Instruction.docx file and follow the
instructions (also shown below).
Student Mathematica 8 Installation Instructions (for license 3310-6097)
1. Install Mathematica 8 by clicking on this link:
a. \\ldsk01\distribution\Mathematica\Mathematica8\Students\M8_ST_Install.bat
2. Activate Mathematica 8
a. Click on the link
https://user.wolfram.com/portal/requestAK/d459741e446f36e19e720e5dfdc47d410ede1fdb
b. Click on Continue without signing in >>
c. Fill out the form:
i. First Name: YourFIRSTName
ii. Last Name: YourLASTName
iii. E-mail: john.doe@loras.edu (replace john.doe with your name)
iv. Select Single Machine
v. Select the Windows platform
vi. Click on Submit
d. Check your e-maill and you should have an e-mail from Wolfram Research Customer Service (Do
NOT follow the download link as you’ve already installed Mathematica!)
e. Copy the activation key, which should look like the following: XXXX-XXXX-XXXXXX
f. Start Mathematica from Start  All Programs  Wolfram Mathematica  Wolfram Mathematica
8
g. Paste your Activation Key into the appropriate box and then click Activate
h. On the next screen, click on I accept the terms of this agreement and click OK
The instructions will take you through the following steps:
1. To start the installation click on the M8_ST_Install.bat and Enter.
2. After installation, you will need to activate the License when you start up Mathematica for the
first time. To start the program locate the Mathematica tile in the Start screen:
The first time you start Mathematics you will
see the screen to the right
(or one similar for Mathematica 8 or 9)
To obtain a password:
Click…Continue
Check the Single-Machine
License option
Enter Name: your name
Organization: Loras College
License Number: L3310-6097
To obtain your password, use the Web option and follow the dialog boxes:
(if the MathID didn’t automatically get entered use 6102-07502-28361)
Start
here
The Rule of Four
This number will
be unique to you.
3) Start up Mathematica using
Homework A.1: In-Class Tutorial
If everything installed correctly and you have obtained your individual key, you should now be
able to start up and work with Mathematica . To start getting a feel for its use, you are going to
work through a short tutorial. The easiest way to get to the tutorial is to open up the web and
navigate to the following website:
http://www.wolfram.com/broadcast/screencasts/handsonstart/
The whole tutorial consists of eight separate tutorials (listed below) and takes about 50 minutes
to run if you let it run continuously. However, when you run it you will most likely want to stop
it intermittently to allow you to complete same actions. Watching it and performing the same
steps will allow you to not only learn the language of Mathematica, but it will start to help you
see how powerful this computational tool is and how it can be useful you.
Hands-on-Start to Mathematica tutorial includes:
Web Tutorial 1 of 8: Notebooks (4:12)
Web Tutorial 2 of 8: Methods to Get Started (10:14)
Web Tutorial 3 of 8: Basic Calculations: (7:58)
Web Tutorial 4 of 8: Basic Graphics (9:45)
Web Tutorial 5 of 8: Making Interactive Models (5:03)
Web Tutorial 6 of 8: Utilizing Data (3:48)
Web Tutorial 7 of 8: Presentations (3:38)
Web Tutorial 8 of 8: Complete Example (4:02)
(total running time: approx.. 50 min)
Completing the notebooks of this tutorial are the first part of
your homework for this lesson. When you have completed
the tutorials, you should save the notebooks and email
them as attachments to your instructor, (clark.merkel@loras.edu).
Please name the notebooks yournameGettingStarted.nb and
yournameCompleteExample.nb. where yourname is your own name
Homework A.2: You are to work through the following guided examples. They are typical of
problems that you might encounter in your Statics course where Mathematica would be a helpful
tool. Save the examples in a notebook and email as an attachment to your instructor as
yournameHomework02.nb.
A) Use Solve command to find the
roots of equations.
i) Solving quadratic equation:
x  5.2t 2  25.4t  15.2
ii) Solving an implicit equation
45sin 2 ( )  2.5 tan(2 )  0.3
(Note that θ will come back in radians)
iii) Solving equation with no real solution:
0  x2  4
B) Use Solve to find solution to set of equations:
In Statics you may often have to solve up to 6 equations simultaneously.
Consider a problem similar to homework:
A crate is supported by three cables as shown.
If the weight is 1000 lb, determine the tension in
each cable.
You would have solved it by setting up the
following three equilibrium equations:
Fx  0
40
36
0
FD  FB
77
75
Fy  0
0  1000 
60
60
60
FC 
FD 
FB
68
77
75
Fz  0
32
27
27
0
FC 
FD 
FB
68
77
75
To solve these three equations in Mathematica:
C) Examples of taking derivatives and calculating integrals:
i) Given a function y  2 x3  3x  5 find the derivative:
ii) Given a function y  2 x3  3x  5 find indefinite integral
iii) Given a function y  2 x3  3x  5 find the definite integral for 0 < t < 10
-------------------------------------------------------------------------------------------
D) Cross and Dot Product:
r  20iˆ  30 ˆj  40kˆ ; and
i) find the Moment given by M  r  F
ii) find the Dot Product of Fproj  uˆ  F
Let uˆ  0.6iˆ  0.8 ˆj  0kˆ ;
F  200iˆ  350 ˆj  100kˆ
iii) find the mixed triple project M proj  uˆ  (r  F )
Note: The Cross Product character in In[54] was made by typing Esc cross Esc
The Dot Product can also be defined with the Dot[ ] function.
E) Plot a graph to see where it has roots.
Given the equation,
4sin 2 ( )  2.5 tan(2 )  0.3
Move all terms to one side and
restate it as a function.
f ( x)  4sin 2 ( )  2.5 tan(2 )  0.3
then set up a Plot from 0 to 5 where
θ is in radians by default.
Note: to get the θ symbol, use
Esc Theta Esc or find it on a Palette
Homework A.3:
When using Mathematica to provide solutions while working homework, you are expected to
printout and turn in the notebook code as part of the problem solution. Usually, just attach it as
an appendix to the problem solution. Just using the words, “Using Mathematica to find the
solution gives….” is not enough. You need to provide enough documentation for a person to
review your work and determine if any mistakes were made in the code. You are encouraged to
start using Mathematica as a tool for solving homework, but you still need to document properly.
On the next page you will find some problems that you are to solve using Mathematica. For this
homework, create a Notebook of your solutions and print out the completed notebook to turn in.
Make sure you use text and section headings to document the process appropriately.
As you work, it is suggested you make use of Mathematica’s help. It’s one of Mathematica’s best
features and will help you if you forget how to do something. The Documentation Center is
easy to navigate and provides you with both syntax and examples of how the functions are used.
There are several different ways you can get help in Mathematica.
1) The feature Free Form Input allows you to start a line with the = sign and then simply type
in the statement as you think it should be typed. Mathematica will try to interpret it for you.
It may take a while for you to and Mathematica to learn to communicate, but it is a good place to
start.
2) When working in a notebook, you can access instant information about a built-in function by
typing ? and the function name, and then press Shift+Enter keys
3) My personal favorite is use of
the Documentation Center. If you
are sure not how to do something,
start with a search. The Help menu
will get you to the Documentation
Center which will both explain and
show how to use Mathematica
functions.
The Documentation Center
offers many topics and links
to related topics. A search
feature allows you to
quickly find information
on the topic or function
you need. Simply type in a
description or key work
of the function you want to
peform, and you’ll likely
find an example very near
to the thing you want to do.
Homework A.3: Problem Solving in Mathematica on your Own.
Problem 1: Solve the linear equation for the value of x
5x + 8 = 9x – 4
Problem 2: Solve a quadratic equation to find its roots:
4x2 - 5 = 5x2 + 20x + 24
Problem 3: Solve a set of two equations:
5x + 5y = 15 and -2 x + 4y = 6
Problem 4: Solve the following set of equations:
3x - 2 y + z = 6
-x + 4 y - z = 4
-2x - 5 y + 8 z = -4
Problem 5: Solve trig equations:
Problem 6: Plot the function:
sin(2x) = 0
(hint: try the Reduce [ ] command)
y = 5 sin(30 x) + 4 cos(29x)
Problem 7: Plot a table of data:
over range of 0 < x < 4π.
(hint: check out the ListPlot[ ] command )
x
0
5
10
15
20
30
35
y
-0.5
1.5
2.5
2.5
3.0
3.5
2.5
Problem 8: Find the volume of a cone with a height h and a base diameter of d by integrating:
Vcone  
h
0
d
h
4
 ( x) 2
dx
Download