PH15720 - If(), Complex Numbers and Symbolic Algebra

Download Report

Transcript PH15720 - If(), Complex Numbers and Symbolic Algebra

PH15720
Laboratory Techniques An Introduction to MATHCAD
Introduction
• The if() function
• Complex Numbers
• Symbolic Algebra
The if() function
• if(condition,Tval,Fval)
• condition evaluated
– True (0)  returns Tval
– False (=0)  returns Fval
Conditional Operators
• From evaluation palette
–
–
–
–
–
= (bold, logical equals) <ctrl =>
> greater than
< less than
 greater than or equal to
 less than or equal to
Boolean Algebra
•
•
•
•
•
False = 0
True = 1 (or 0)
Use multiplication for AND
Use addition for OR
(x>5)•(x<8)
– True if x>5 and x<8
• (x<3)+(x>16)
– True if x<3 or x>16
Boolean algebra #2
1 .5
1 .5
1
( x 5 )  ( x 8 )
( x 3 )
( x 1 6)
0 .5
0
0
0
0
5
10
x
15
20
20
Magnetic field due to
long straight wire #1
• Different equations inside and
outside conductor
• Inside:
r
I

B( r )
• Outside:
B( r )
0
2  R wire
 0 I
2   r
2
Magnetic Field due to
long straight wire #2
• Combine two equations using if()
function
B( r)
 0 I 1

2  r
Outside
B( r )
 0 I
B( r )

r
2
2  R
wire
Inside
 0 I
2 
if r  R
wire 
Combined with if()
r

1
2
R wire r
Magnetic Field due to
long straight wire #3
R wire
3 1 0
4
B( r ) 2 1 0
4
1 1 0
4
0
0
0 .0 02
0 .0 04
0 .0 06
r
B R wire  2 10
4
T
0 .0 08
Complex Numbers in
MathCAD
• Handled same as other numbers
• Full range of complex maths
• Put i (or j) directly after complex
number
• Enter i as 1i
• Use |x| to get modulus
• Use arg() to get argument
• Avoid using i as variable when using
complex numbers
Complex Numbers #1
(1
2i)
(1
2i)  ( 3
(1
2i)
1
2i
3
4i
(3
(3
 0.44
4i)  4
4i)  5
4i)  2
0.08i
6i
10i
2i
• Basic complex
maths
Complex Numbers #2
3
1
2i  1.272
1
2i  1.22
0.786i
0.472i
• Principle roots
found
• Need to get
other roots by
hand or by
using
polyroots()
Symbolic Algebra #1
• Manipulate equations rather
than numbers
• Symbolic Palette
–
–
–
–
–
Evaluate
Simplify
Expand
Substitute
Solve

simplify 
expand, 
substitute, =  
solve,  
Symbolic Algebra #2
• Not covered in depth here
• Handout gives resource centre
references
• Worth a look
The tin can problem #1
• From example sheet - solve using
mathCAD
• A manufacturer of tin cans wishes to
maximise the volume contained in a
can, whilst minimising the amount of
metal used to construct the can.
Show that, for given amount of metal,
the volume of a can is maximised
when the radius is half the height.
The tin can problem
Overview of Solution
• Assume Area of tin constant
• Obtain expression for Volume in
terms of Area and radius
• Find dVol/dr
• dVol/dr will be 0 at max volume
so use this to find r
• Substitute to find r in terms of h
The tin can problem #2
• Need to find when dVol/dr=0
• Write down expressions for Volume &
Area
• Use bold, logical equals sign
2

Vol  r h
2





Area 2  r h 2  r
The tin can problem #3
• Copy & Paste expression for
Area & solve for h
2





Area 2  r h 2  r solveh

1  Area 2  r
2
(  r)
2
The tin can problem #4
• Copy & paste expression for Vol
• Substitute expression for h
1  Area 2  r
2

Vo l  r h substitute
h
2
(  r )
2
1 
2
Vo l
r Area 2  r
2
The tin can problem #5
• Use symbolic differentiation to
find dVol/dr
d 1 
2


r Area 2  r
dr 2
1
2


Area 3  r
2
• This will be 0 at maximum
The tin can problem #6
• Solve for dVol/dr = 0 to find r
1
1
2
Area 3  r
2
0 solve  r
1   
2
6 (  Area)
( 6  )
1
1   
2
6 (  Area)
( 6  )
• 2 solutions, copy +ve
The tin can problem #7
• Have expression for r in terms of
Area
• Substitute expression for Area
1
1
1   
2
6 (  Area)
substitute  Area 2  r h
( 6  )
2
2   r
1     
6  2 rh

(6  )
• Now have expression for r in
terms of r and h
2
2  r
2
The tin can problem #8
• Take expression for r in terms of
r and h
• Add r=
• Solve for r to get answer
1
1     
r
6  2 rh
( 6  )
2  r
2
2
0
solve  r
1
h
2
Summary
• Modelling a discontinuous
universe with the if() function
• Complex Numbers
• Symbolic Algebra
Assessment
•
•
•
•
Next Week
In class
Processing experimental
Data
Assessment
Golden Rules
•
•
•
•
•
•
Comment & Explain
Get paper size right (A4)
Layout/Page breaks
Use MathCAD 8 format
Name/UserID on Header/Footer
Attempt everything