Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

43
[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer [email protected] Engr/Math/Physics 25 Chp11: MuPAD Misc

description

Engr/Math/Physics 25. Chp11: MuPAD Misc. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer [email protected]. Using Greek Letters. Can only do ONE letter at time Not ALL std Ltrs convert to Greek Also Use Ctrl+G. Some Letters do NOT have conversions - PowerPoint PPT Presentation

Transcript of Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

Page 1: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 1

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Bruce Mayer, PELicensed Electrical & Mechanical Engineer

[email protected]

Engr/Math/Physics 25

Chp11: MuPAD

Misc

Page 2: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 2

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Using Greek Letters

Can only do ONE letter at time

Not ALL std Ltrs convert to Greek• Also Use

Ctrl+G

Some Letters do NOT have conversions

Spaces do NOT Convert• Select

ONLY letters; NOT letters and a space

Page 3: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 3

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TypeSetting Symbols

Page 4: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 4

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Greek from Command Bar Make Expression

Use Assignment Operator → :=

Now type A*cos( *t+ )

Next Pick-off the Greek from the COMMAND BAR

Click the Down Arrow

tAh cos

Page 5: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 5

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Greek from Command Bar Then pick off omega

& phi from the pull-down list with cursor in the right spot in the “h” expression

Then hit Enter to create symbolic expression

Some Other Expressions with Greek Pulled From the Command Bar

Page 6: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 6

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

“HashTag” PlaceHolders PlaceHolder for

items from the Command Bar look Something like: #f, or #x • Sort of Like

“HashTag” in Twitter Let take an Anti-

Derviative, and Calculate some Integrals

Use the Command Bar Integral Pull-Down

Pick first one to expose Place Holders for fcn & var

7

3 222222 11

11

11 dy

ydy

ydy

y

Page 7: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 7

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

“HashTag” PlaceHolders Replace“HashTags”

For Variable End-Point Definite Integral

The HastTags

The symbolic Definite Integral

The NUMERIC Definite Integral(s)

7

3 222222 11

11

11 dy

ydy

ydy

y

Page 8: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 8

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Assignment vs. Procedure := does NOT Create

a function• It assigns a complex

expression to an Abbreviation

To Create A Function (MuPad “Procedure”) include characters ->

Comparing →

Page 9: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 9

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Quick Plot by Command Bar Find

Plot Icon

Then Fill in the HashTag the the desired Function; say

The Template

The Result after filling in HashTag

xxy sin

Page 10: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 10

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Adjust Plot MuPad picks the

InDep Var limits ±5 Write out Function to

set other limits

2X-Clik the Plot to Fine Tune Plot formatting Using the Object Browser

Page 11: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 11

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Object Brower (2X Clik Plot)

Page 12: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 12

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

delete → early & often In MuPAD there is NO WorkSpace

Browser to see if a variable has been evaluated and currently contains a value

Use “delete(p)”, where “p” is the variable to be cleared in a manner similar to using “clear” in MATLAB

When in Doubt, DELETE if ReUsing a variable symbol

Page 13: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 13

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

delete → early & often BOOBY PRIZE → A Variable defined in

one WorkBook will CARRY OVER into OTHER WorkBooks• The Deleted Assignment in the original

WorkBook can be Recovered by using Evaluate

When in doubt → DELETE

See File: Multiple_Assigns_Deletions_1204

Page 14: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 14

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TYU 11.2-1 For a A very Good Exercise See file

• ENGR25_TYU11_2_1_Expressions_Functions_1204.mn

Page 15: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 15

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TYU11.3 Another Good Exercise

• ENGR25_TYU11_3_Expressions_Functions_1204.mn

Page 16: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 16

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Inserting Images into MuPAD Unlike the MATLAB Command Window,

IMAGES can be imported into Text Regions of a MuPAD WorkBook

Copy the Image then

See File• Insert-Graphic_1204.mn

– Contains some other“tips” on MuPAD as well

Page 17: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 17

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TYU11.5 → Derivatives Take Some Derivatives

• ENGR25_TYU11_5_Derivatives_1204.mn

Page 18: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 18

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TYU11.5 → AntiDerivatives Do Some Integration

• ENGR25_TYU11_5_Integration_1204.mn

Page 19: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 19

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Power Series General Power Series:

• A form of a GENERALIZED POLYNOMIAL Power Series Convergence Behavior

• Exclusively ONE of the following holds Truea) Converges ONLY for x = 0 (Trivial Case)b) Converges for ALL x c) Has a Finite “Radius of Convergence”, R

n

n

nn

kk xaxaxaxaxaxa

0

33

22

11

00

Page 20: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 20

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Functions as Power Series Many Functions can be represented as

Infinitely Long PolyNomials Consider this Function and Domain

The Geometric Series form of f(x)

Thus

1for1

1

x

xxf

xfxxxxxxx

n

n

nk

0

3210 1111111

1

1for1

10

xxx

xfn

n

n

Page 21: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 21

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series Consider some general Function, f(x),

that might be Represented by a Power Series

Thus need to find all CoEfficients, an, such that the Power Series Converges to f(x) over some interval. Stated Mathematically Need an so that:

Rxxfxan

n

nn

forconverges

0

n

n

nn xaxaxaxaaxf

0

33

2210

Page 22: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 22

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series If x = 0 and if f(0) is KNOWN then

• a0 done, 1→∞ to go….

Next Differentiate Term-by-Term

Now if the First Derivative (the Slope) is KNOWN when x = 0, then

000000 003

32

210 faaaaaaf

n

n

nn xnaxaxaxaa

dxxdf

1

134

2321 432

011

34

2321

0

0040302

xx dx

dfaaaaaadxdf

Page 23: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 23

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series Again Differentiate Term-by-Term

Now if the 2nd Derivative (the Curvature) is KNOWN when x = 0, then

n

n

nn xannxaxaa

dxfd

2

224322

2

134232

02

2

222

4320

2

2

2020340232

xx

dxfdaaaaa

dxfd

Page 24: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 24

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series Another Differentiation

Again if the 3rd Derivative is KNOWN at x = 0

Recognizing the Pattern:

n

n

nn xannnxaxaa

dxfd

3

324433

3

2134523423

03

3

332

4430

3

3

6060345023423

xx dx

fdaaaaadx

fd

!! 0

0n

dxfd

adx

fdan xn

n

nx

n

n

n

Page 25: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 25

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series Thus to Construct a Taylor (Power)

Series about an interval “Centered” at x = 0 for the Function f(x)• Find the Values of ALL the Derivatives of

f(x) when x = 0• Calculate the Values of the

Taylor Series CoEfficients by• Finally Construct the

Power Series from the CoEfficients

!0

ndx

fd

a xn

n

n

n

n

nn xaxf

0

Page 26: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 26

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Example Taylor Series for ln(e+x) Calculate the Derivatives

Find the Values of the Derivatives at 0

322

3322

21111lnxexedx

dxexedx

dxe

xedxd

dxfddxfddxdf

3322

033

022

02

021

011

01

eeeeee

dxfddxfddxdf xxx

Page 27: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 27

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Example Taylor Series for ln(e+x) Generally Then the CoEfficients

The 1st four CoEfficients

1for!11 1

0

ne

ndxfd n

n

xnn

1for1!

!11

!

1

1

0

nenn

en

ndxfd

a n

nn

n

xnn

n

Page 28: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 28

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Example Taylor Series for ln(e+x) Then the Taylor Series

1

1)1(1)ln(n

n

nn

enxxe

n

nn

nn

nn x

enxaxaxaxe

1

10

01

00

1ln

Page 29: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 29

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series at x ≠ 0 The Taylor Series “Expansion” can

Occur at “Center” Values other than 0 Consider a function

stated in a series centered at b, that is:

Now the Radius of Convergence for the function is the SAME as the Zero Case:

n

n

nn bxaxf

0

bRxbRbRbbxbR

RbxRRbx

Page 30: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 30

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Taylor Series at x ≠ 0 To find the CoEfficients

need (x−b) = 0 which requires x = b, Then the CoEfficient Expression

The expansion about non-zero centers is useful for functions (or the derivatives) that are NOT DEFINED when x=0• For Example ln(x) can NOT be expanded

about zero, but it can be about, say, 2

!! nbf

ndx

fd

an

bxn

n

n

Page 31: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 31

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Example Expand x½ about 4 Expand about b = 4: The 1st four Taylor CoEfficients

xxf

Page 32: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 32

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Example Expand x½ about 4 SOLUTION: Use the CoEfficients to Construct the

Taylor Series centered at b = 4

0

)(n

nn bxax

Page 33: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 33

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Example Expand x½ about 4 Use the Taylor Series centered at b = 4

to Find the Square Root of 3

4

00

)3()3(3n

nn

n

nn baba

432 )43(16384

5)43(5121)43(

641)43(

412

432 )1(16384

5)1(5121)1(

641)1(

412

0003.00020.00156.025.02

1.7320508 MATLABBy 7321.12679.02

Page 34: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 34

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Expand About b=1, ln(x)/1 Da1 := diff(ln(x)/x, x)

Db2 := diff(Da1, x)

Dc3 := diff(Db2, x)

Dd4 := diff(Dc3, x)

ReCall thatln(1) = 0

0112

1

xdx

df

51

4

4

1500

xdx

fd

0

111

41

3

3

xdx

fd

51

2

2

130

xdx

fd

Page 35: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 35

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Expand About b=1, ln(x)/1 ln(x)/x, x

f0 := taylor(ln(x)/x, x = 1, 0)

f1 := taylor(ln(x)/x, x = 1, 1)

f2 := taylor(ln(x)/x, x = 1, 2)

Page 36: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 36

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Expand About b=1, ln(x)/1 f3 := taylor(ln(x)/x, x = 1, 3)

f4 := taylor(ln(x)/x, x = 1, 4)

d6 := diff(ln(x)/x, x $ 5)

0

1274

61

5

5

xdx

fd

!5

11274!4

1150!3

1111!2

113!11

!00ln

54321

xxxxxx

Page 37: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 37

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Expand About b=1, ln(x)/1 plot(f0, f1, f2, f3, f4, f5, x =0.5..3, GridVisible = TRUE,

LineWidth = 0.04*unit::inch, Width = 320*unit::mm, Height = 180*unit::mm,AxesTitleFont = ["sans-serif", 24],TicksLabelFont=["sans-serif", 16])

Page 38: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 38

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Page 39: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 39

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Page 40: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 40

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Page 41: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 41

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TYU 11.5 → Sums & Series Exercise Taylor’s Series & Sums

• ENGR25_TYU11_5_6789_Taylor_Sums_Limits_1204.mn

Page 42: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 42

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

TYU11.6 → ODEs Do an ODE Solution

• file = ENGR25_TYU11_6_ODE_1204.mn– By: File → Export → PDF

Page 43: Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege

[email protected] ENGR-25_Lec-27_MuPAD_Miscellaneous-n-TYUs.pptx 43

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

All Done for Today

It’s AllGREEKto me…