mech7220-mathematica

# mech7220-mathematica - 2 A Mathematica Primer 2.1 Basics...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: 2 A Mathematica Primer 2.1 Basics Mathematica is a very powerful package for performing symbolic and numerical mathematics. It has a fairly steep learning curve, and takes some patience and involves some frustration to become adept at using it. My experience with previous students is that once learned, Mathematica becomes an indispensable tool in their academic and research work. The point of these notes is to present a basic introduction to the package. Perhaps the best way to start is with an example. The 1–D convective–diffusive problem discussed in class appeared as Pe d T d x = d 2 T d x 2 (1) T (0) = 0 , T (1) = 1 (2) where T = T- T T L- T , x = x L , Pe = uL α The problem is ”well posed” insofar as sufficient information is given (a second order ODE and 2 boundary conditions) to obtain a solution. Start up Mathematica and type the following information in to the notebook window (or cut and paste – that should work): de = pe t’[x] -t’’[x] == 0; bc1 = t[0] == 0; bc2 = t[1] == 1; soln = DSolve[{de, bc1, bc2}, t[x], x][[1,1]] Now, with the cursor anywhere within the block of four lines, do ”shift+enter”. You should get something like this Out[4]= t[x] -> (-1 + E^(pe x))/(-1 + E^pe) The Out[4] will probably have a different number than 4; that is irrelevant. What is important is that the output returns the solution to the boundary value problem. Now for some specific and some general points regarding Mathematica : 1. Mathematica works as an line interpreter as opposed to the batch process of Matlab. That is, it executes commands on a line–by–line basis, and keeps the results in memory. Several commands can be combined into a single block by using the semicolon (;) at the end of the line, per the example above. You can position your cursor at any vertical position in your notebook and re–execute an old command (via shift+enter), or edit an old command and re–execute it, or type in a new command. This is also distinct from Matlab. 2. Mathematica begins all intrinsic functions and mathematical constants with upper case letters, i.e., Sin[x] for sin( x ), Pi for π , and I for i = √- 1. It is strongly advised that you use lower case letters for all variables and parameters in your solution. By doing so you will avoid any conflict with a Mathematica –defined function or constant. For example, the temperature was denoted as t[x] ....
View Full Document

## This note was uploaded on 09/24/2011 for the course MECH 7220 taught by Professor Staff during the Fall '10 term at Auburn University.

### Page1 / 4

mech7220-mathematica - 2 A Mathematica Primer 2.1 Basics...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online