applied linear algebra in geoscience using...

29
Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB

Upload: lethuan

Post on 25-Jul-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Applied Linear Algebra in Geoscience Using MATLAB

Applied Linear Algebra in Geoscience Using MATLAB

Contents

Applied Linear Algebra in Geoscience Using MATLAB

Getting Started

Creating Arrays

Mathematical Operations with Arrays

Using Script Files and Managing Data

Two-Dimensional Plots

Programming in MATLAB

User-Defined Functions and Function Files

Polynomials, Curve Fitting, and Interpolation

Applications in Numerical Analysis

Three-Dimensional Plots

Symbolic Math

Matrices

Linear equations

Determinants

Eigenvalues and eigenvectors

Orthogonal vectors and matrices

Vector and matrix norms

Gaussian elimination and the LU dec.

Linear system applications

Gram-Schmidt decomposition

The singular value decomposition

Least-squares problems

Implementing the QR factorization

The algebraic eigenvalue problem

Linear Independence Basis of a Subspace The Rank of a Matrix

Applied Linear Algebra in Geoscience Using MATLAB

Learn MuPAD byStare & Compare (examples)HackingAnd, if all else fails, then HELP!

MuPAD research group at the University of Paderborn, Germany originally developed this symbolic-manipulation software

MuPAD is a part a generic class of Software called a “Computer Algebra System” (CAS).

The MathWorks purchased MuPAD to replace the previous “Symbolic Math Kernal” written by MapleSoft

Background

Applied Linear Algebra in Geoscience Using MATLAB

Capabilities

Create SYMBOLIC expressions and manipulate them algebraically.

Obtain SYMBOLIC and numeric solutions to algebraic and transcendental equations.

Perform SYMBOLIC LINEAR ALGEBRA operations, including obtaining expressions

for determinants, matrix inverses, and others.

Perform SYMBOLIC differentiation and integration

Evaluate limits and series SYMBOLICALLY.

Obtain SYMBOLIC solutions to Ordinary Differential Equations (ODEs).

Solve ORDINARY DIFFERENTIAL EQUATIONS in terms of special functions or series.

Applied Linear Algebra in Geoscience Using MATLAB

Symbolic Computation

Numerical Symbolic

Variables Represent NumbersVariables are Symbols; e.g., x, y, z, β, θ, σ

Answers can Only be NumbersAnswers can contain Variables and Functions

Numeric Computation can be done using Standard Programming Languages

Symbolic computations are not similar to standard programming languages –they use symbolic Manipulations

The Differences Between Symbolic and Numeric Computation

Applied Linear Algebra in Geoscience Using MATLAB

NoteBoook

• MuPAD creates within MATLAB its own working SubWindows Called NoteBooks

The User works/types in the “NoteBooks”NoteBooks saved with extension: .mn

• For MuPAD beginers it’s best start at the MuPAD “Welcome” screen

• At the MATLAB Command Prompt type mupadwelcome

Applied Linear Algebra in Geoscience Using MATLAB

NoteBook Regions

In MATLAB command window type mupad

CALC Regions

Applied Linear Algebra in Geoscience Using MATLAB

Capabilities

TEXT Regions

Applied Linear Algebra in Geoscience Using MATLAB

Capabilities

OutPut Regions

Applied Linear Algebra in Geoscience Using MATLAB

Evaluation

• The CALCULATION regions in MuPAD can be Inserted, Deleted, Edited

• After Editing, We may have to EVALUATE the edit using the TOOL or PULL DOWN MENU

• If a change in an OUTPUT Region does NOT happen as expected; then be SURE to

EVALUATE the CALC region “EVALUATE ALL” often works best

Place the cursor IN the CALC RegionThen Hit the Evaluate Button to initiate the CalculationNote also the ASSIGNMENT Operator :=

After EVALUATE

Applied Linear Algebra in Geoscience Using MATLAB

Syntax & Structure

TEXT regions do NOT have aleft BracketCALC & OUTPUT Regions DOhave a Left Bracket

Interaction with INTEGERSProduces a SYMBOLIC OutPutUsing a decimal Point Producesa NUMBER Result

Applied Linear Algebra in Geoscience Using MATLAB

I1

E

PI

ji

e

log e-Baseln

log b-Baselog

b

Reserved Symbols

The Logarithms

A Decimal

Syntax & Structure

Applied Linear Algebra in Geoscience Using MATLAB

FLOAT command

The float command produces a DECIMAL Result for an otherwise integer display

The float(%) command changes the LAST EVALUATED result to a decimal; not necessarily the value right above (or below) the float(%) command

Float(%) Confusion

Caveat on float(%)

Bottom Expression Evaluated LAST

First Expression Edited then Eval’d

Applied Linear Algebra in Geoscience Using MATLAB

Command Bar

Shortcuts to Commands in:The General Math MenuExpand SimplifyFactor CombineNormalize RewriteEvaluate Solve

Items on the Command barDerivatives Limits SumsIntegrals Rewrite Expressions ProductsSolve Equations Simplify Evaluate with x = aNumerical Evaluation and Rounding Equality Tests AssignmentMath Operators Factorials Function DefinitionTrig Functions Exponentials and Logs Piecewise DefinitionsReserved Symbols Greek Letters Physical UnitsMatrices and Vectors 2D Plot 3D Plot

Items on the Command Bar use# as a PlaceHolder that MUST be

replaced

Applied Linear Algebra in Geoscience Using MATLAB

Expression vs. Function

An EXPRESSION Example A MuPAD Function is called a ProcedureConstruction looks like an anonymous fcn

Use “->” in place of @

Applied Linear Algebra in Geoscience Using MATLAB

Plot

Plot from a Procedure (UDF) Plot from an Expression

No Semi-Colon

Applied Linear Algebra in Geoscience Using MATLAB

Printing from MuPAD

Each NoteBook must be Printed Separately

Use standard Windows Pull-Down Menu:File → Print

Applied Linear Algebra in Geoscience Using MATLAB

Copy & Paste

Example of the Bitmap into PPT shown below

Pasting in MSWord requires TWO Copy-n-Paste Operations

1. Paste TEXT Regions NORMALLY2. Paste “Script Math” Using “Paste Special”

Copying GRAPHS requires at THIRD Operation

Click the Graph to Activate the Plot Menu Bar

The Thick border indicates graphic has been copied to the clipboard

Applied Linear Algebra in Geoscience Using MATLAB

Algebra

yyByyyA 2057515223

Given Expressions

For This situation find

The Product A B in Simplest FormThe Quotient A/B in Simplest FormEvaluate A+B at y = 8.3 in

Symbolic formNumeric form

Applied Linear Algebra in Geoscience Using MATLAB

Solve(eqn)

Applied Linear Algebra in Geoscience Using MATLAB

Solve Systems of Eqns

35121

214311

111211

zyx

zyx

zyx

364

202

117342

zyx

zyx

zyx

Note the use of SQUARE Brackets

Applied Linear Algebra in Geoscience Using MATLAB

Solve :: numeric

xx cos7142

Some eqns do NOT have Algebraic solution, such as

Solve by regular MATLAB → fzeroUse fplot for 0cos7142 xx

-5 -4 -3 -2 -1 0 1 2 3 4 5-25

-20

-15

-10

-5

0

5

10

X: -2.76

Y: 0.1141

X: 2.76

Y: 0.1141

Solutions ≈ x = ±2.76

ParabCos = @(x) x.^2-14 - 7*cos(x);fplot(ParabCos,[-5 5]), gridsL = fzero(ParabCos, -3)sR = fzero(ParabCos, +3)

RESULT:sL =

-2.7460sR =

2.7460

Applied Linear Algebra in Geoscience Using MATLAB

Check with MuPAD

Now use numeric modifier in MuPAD

No Symbol Soln

Only ONE Solution

LEFT Solution

RIGHT Solution

0cos7142 xx

Solve :: numeric

Applied Linear Algebra in Geoscience Using MATLAB

Capabilities

Click the “Object Browser” ButtonExplore the options in the two boxes at right (click upper item first)

RIGHT Click the Graphic, then Follow the “Wizard” instructions

Applied Linear Algebra in Geoscience Using MATLAB

Derivatives

Applied Linear Algebra in Geoscience Using MATLAB

Capabilities

Given: )3sinh(5cosh vvu

3.0vdv

du

Applied Linear Algebra in Geoscience Using MATLAB

Integrals

Applied Linear Algebra in Geoscience Using MATLAB

ODEs

Applied Linear Algebra in Geoscience Using MATLAB

ODEs

02

2

kydx

yd

Solve this ODE

With Boundary Conditions

010 0 xdxdyy

With Constraint

0k

The assume command notifies MuPAD about the Constraint