PH15720 Laboratory Techniques - An Introduction to MATHCAD.

26
PH15720 PH15720 Laboratory Techniques - Laboratory Techniques - An Introduction to MATHCAD An Introduction to MATHCAD

Transcript of PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Page 1: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

PH15720PH15720

Laboratory Techniques -Laboratory Techniques -

An Introduction to MATHCADAn Introduction to MATHCAD

Page 2: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

IntroductionIntroduction

• The if() functionThe if() function• Complex NumbersComplex Numbers• Symbolic AlgebraSymbolic Algebra

Page 3: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The if() functionThe if() function

• if(condition,Tval,Fval)if(condition,Tval,Fval)• condition evaluatedcondition evaluated

– True (True (0) 0) returns Tval returns Tval– False (=0) False (=0) returns Fval returns Fval

Page 4: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Conditional OperatorsConditional Operators

• From evaluation paletteFrom evaluation palette– = (bold, logical equals) <ctrl =>= (bold, logical equals) <ctrl =>– > greater than> greater than– < less than< less than greater than or equal togreater than or equal to less than or equal toless than or equal to

Page 5: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Boolean AlgebraBoolean Algebra

• False = 0False = 0• True = 1 (or True = 1 (or 0)0)• Use multiplication for ANDUse multiplication for AND• Use addition for ORUse addition for OR• (x>5)•(x<8)(x>5)•(x<8)

– True if x>5 and x<8True if x>5 and x<8

• (x<3)+(x>16)(x<3)+(x>16)– True if x<3 or x>16True if x<3 or x>16

Page 6: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Boolean algebra #2Boolean algebra #2

0 5 10 15 200

0.5

1

1.51.5

0

x 5( ) x 8( )

x 3( ) x 16( )

200 x

Page 7: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Magnetic field due to long Magnetic field due to long straight wire #1straight wire #1

• Different equations inside and Different equations inside and outside conductoroutside conductor

• Inside:Inside:

• Outside:Outside:

B r( ) 0I r

2 R wire2

B r( ) 0 I

2 r

Page 8: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Magnetic Field due to long Magnetic Field due to long straight wire #2straight wire #2

• Combine two equations using if() Combine two equations using if() functionfunction

B r( ) 0 I

2 if r R wire

r

R wire2

1

r

OutsideOutside

InsideInside

Combined with if()Combined with if()

B r( ) 0 I

2 1

r

B r( ) 0 I

2 r

R wire2

Page 9: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Magnetic Field due to long Magnetic Field due to long straight wire #3straight wire #3

0 0.002 0.004 0.006 0.0080

1 10 4

2 10 4

3 10 4

B r( )

R wire

r

B R wire 2 104 T

Page 10: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Complex Numbers in Complex Numbers in MathCADMathCAD

• Handled same as other numbersHandled same as other numbers• Full range of complex mathsFull range of complex maths• Put i (or j) directly after complex numberPut i (or j) directly after complex number• Enter i as 1iEnter i as 1i• Use |x| to get modulusUse |x| to get modulus• Use arg() to get argumentUse arg() to get argument• Avoid using i as variable when using Avoid using i as variable when using

complex numberscomplex numbers

Page 11: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Complex Numbers #1Complex Numbers #1

• Basic complex Basic complex mathsmaths

1 2i( ) 3 4i( ) 4 6i

1 2i( ) 3 4i( ) 5 10i

1 2i( ) 3 4i( ) 2 2i

1 2i

3 4i0.44 0.08i

Page 12: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Complex Numbers #2Complex Numbers #2

• Principle roots Principle roots foundfound

• Need to get Need to get other roots by other roots by hand or by using hand or by using polyroots()polyroots()

1 2i 1.272 0.786i

31 2i 1.22 0.472i

Page 13: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Symbolic Algebra #1Symbolic Algebra #1

• Manipulate equations rather than Manipulate equations rather than numbersnumbers

• Symbolic PaletteSymbolic Palette– Evaluate Evaluate – Simplify Simplify simplify simplify – Expand Expand expand,expand, – Substitute Substitute substitute, substitute, = = – SolveSolve solve, solve,

Page 14: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

Symbolic Algebra #2Symbolic Algebra #2

• Not covered in depth hereNot covered in depth here• Handout gives resource centre Handout gives resource centre

referencesreferences• Worth a lookWorth a look

Page 15: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #1The tin can problem #1

• From example sheet - solve using From example sheet - solve using mathCADmathCAD

• A manufacturer of tin cans wishes to A manufacturer of tin cans wishes to maximise the volume contained in a maximise the volume contained in a can, whilst minimising the amount of can, whilst minimising the amount of metal used to construct the can. Show metal used to construct the can. Show that, for given amount of metal, the that, for given amount of metal, the volume of a can is maximised when the volume of a can is maximised when the radius is half the height.radius is half the height.

Page 16: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem The tin can problem Overview of SolutionOverview of Solution

• Assume Area of tin constantAssume Area of tin constant• Obtain expression for Volume in Obtain expression for Volume in

terms of Area and radiusterms of Area and radius• Find dVol/drFind dVol/dr• dVol/dr will be 0 at max volume so dVol/dr will be 0 at max volume so

use this to find ruse this to find r• Substitute to find r in terms of hSubstitute to find r in terms of h

Page 17: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #2The tin can problem #2

• Need to find when dVol/dr=0Need to find when dVol/dr=0• Write down expressions for Volume & Write down expressions for Volume &

AreaArea• Use bold, logical equals signUse bold, logical equals sign

Vol r2 h

Area 2 r h 2 r2

Page 18: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #3The tin can problem #3

• Copy & Paste expression for Area & Copy & Paste expression for Area & solve for hsolve for h

Area 2 r h 2 r2 solve h

1

2

Area 2 r2

r( )

Page 19: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #4The tin can problem #4

• Copy & paste expression for VolCopy & paste expression for Vol• Substitute expression for hSubstitute expression for h

Vol r2 h substitute h

1

2

Area 2 r2

r( ) Vol

1

2r Area 2 r

2

Page 20: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #5The tin can problem #5

• Use symbolic differentiation to find Use symbolic differentiation to find dVol/drdVol/dr

• This will be 0 at maximumThis will be 0 at maximum

r

1

2r Area 2 r

2d

d

1

2Area 3 r

2

Page 21: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #6The tin can problem #6

• Solve for dVol/dr = 0 to find rSolve for dVol/dr = 0 to find r

• 2 solutions, copy +ve2 solutions, copy +ve

1

2Area 3 r

2 0 solve r

1

6 ( )6 Area( )

1

2

1

6 ( )6 Area( )

1

2

Page 22: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #7The tin can problem #7

• Have expression for r in terms of Have expression for r in terms of AreaArea

• Substitute expression for AreaSubstitute expression for Area

• Now have expression for r in terms Now have expression for r in terms of r and hof r and h

1

6 ( )6 Area( )

1

2 substitute Area 2 r h 2 r2

1

6 ( )6 2 r h 2 r

2

1

2

Page 23: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

The tin can problem #8The tin can problem #8

• Take expression for r in terms of r Take expression for r in terms of r and hand h

• Add r=Add r=• Solve for r to get answerSolve for r to get answer

r1

6 ( )6 2 r h 2 r

2

1

2 solve r

0

1

2h

Page 24: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

SummarySummary

• Modelling a discontinuous universe Modelling a discontinuous universe with the if() functionwith the if() function

• Complex NumbersComplex Numbers• Symbolic AlgebraSymbolic Algebra

Page 25: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

AssessmentAssessment

• Next WeekNext Week• In classIn class• Processing experimentalProcessing experimental• DataData

Page 26: PH15720 Laboratory Techniques - An Introduction to MATHCAD.

AssessmentAssessmentGolden RulesGolden Rules

• Comment & ExplainComment & Explain• Get paper size right (A4)Get paper size right (A4)• Layout/Page breaksLayout/Page breaks• Use MathCAD 8 formatUse MathCAD 8 format• Name/UserID on Header/FooterName/UserID on Header/Footer• Attempt everythingAttempt everything