12.010 Computational Methods of Scientific Programming Lecture 13 - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

12.010 Computational Methods of Scientific Programming Lecture 13

Description:

Started looking at Mathematica and went over the basic ... Beginner's Guide to Mathematica. Electronic Book as well!!* Web Sites* http://www.wolfram.com ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 11
Provided by: ThomasA85
Learn more at: http://www-gpsg.mit.edu
Category:

less

Transcript and Presenter's Notes

Title: 12.010 Computational Methods of Scientific Programming Lecture 13


1
12.010 Computational Methods of Scientific
ProgrammingLecture 13
  • Todays lecture
  • More Mathematica functionality
  • Mathematica Version of poly_area.f
  • Web page http//www-gpsg.mit.edu/tah/12.010

2
Review of Lecture 12
  • Started looking at Mathematica and went over the
    basic features
  • Front End / Kernel
  • Notebooks
  • Arbitrary Numerical Precision
  • Programming Control Features

3
Resources
  • Mathematica Book
  • Third Party Books
  • Programming in Mathematica
  • Beginners Guide to Mathematica
  • Electronic Book as well!!
  • Web Sites
  • http//www.wolfram.com
  • http//www.mathsource.com
  • Internal
  • ? and ??
  • Help

4
Conversion of Units
  • Add the units package ltltMiscellaneaousUnits
  • Convertquantity with units, new units
  • ConvertTemperaturenumber, old scale, new scale
  • SI , MKS , CGS

5
Variables and Scope
  • Variable Types (optional, but can be helpful)
  • Contexts (Global and others)
  • Local variables in Module
  • Mathematica iterator in Do, Table, and others
  • max, symbol, max, symbol, min, max
  • symbol, min, max, increment

6
Assignment and Delayed Assignment
  • Assignment and delayed assignment
  • is immediate
  • is delayed
  • Functions that remember their values
  • fx_ fx function of x
  • Mathematica looks for specific definitions first,
    so it checks first for previously calculated
    values are checked
  • ? yields the usage, if defined fusage
    "string"
  • ?? yields the definition and all the values

7
String Operations
  • ToString and ToExpression
  • String Manupulation
  • StringTake
  • StringDrop
  • StringJoin
  • Sorting strings
  • Characters from strings

8
Importing and Exporting
  • Directories and Path
  • Importing Data
  • Images
  • Saving Variables (Save )
  • Saving Kernel States (DumpSave )

9
Mathematica Programming
  • Evolution of code
  • Set of statements
  • Group into functions
  • Package of functions
  • Use of Module
  • no compiling
  • Mathematica Compile
  • logical, integer, real, or complex arguments
  • single value returned (not a list)
  • speeds up numerical calculations

10
Translating poly_area.f
  • Expressions go from Mathematica to FORTRAN with
    FortranForm
  • Basic Translation from FORTRAN to Mathematica
  • Possible, but not Mathematica savvy
  • Mathematica style
  • Descriptive variable names (begin with lower case
    and use embedded capitals)
  • Short functions that use the power of Mathematica
  • Use lists instead of arrays
  • "map" over lists rather than loop
  • Example of poly_area.f -gt polyArea
Write a Comment
User Comments (0)
About PowerShow.com