mathcad homework

6

Click here to load reader

Upload: sujith

Post on 10-Mar-2015

88 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Mathcad Homework

MathCAD Homeworkby First_name Last_name

MM/DD/YY

Basic calculations (solution to quadratic equation: ax2 + bx + c = 0)

a 1 b 2 c 3

x1b b

24 a c

2 a x2

b b2

4 a c

2 a

x1 1 1.414i x2 1 1.414i

checking results:

f x( ) a x2

b x c

f x1 0 f x2 0

Plotting a function using a range variable

x 5 4.95 3 x

-5

-4.95

-4.9

-4.85

-4.8

-4.75

-4.7

-4.65

-4.6

-4.55

-4.5

-4.45

-4.4

-4.35

-4.3

...

4 2 0 20

5

10

15

20

f x( )

x

Using units and significant digit display

m 100 lb v 60 mph a 20ft

sec2

p m v p 1.217 103

m kg

s

F m a F 62.2 lbf

Page 2: Mathcad Homework

Symbolic Algebra

x

2x 3 x y

x 2( )2

y 2( )=

x y( )

6 y y 2( ) 3 y 2( ) 4

3 y 2

y 2( ) 3 y 2( ) 6 y 4

3 y 2

x 5( )0

2 0.734i x 5( )1

2 0.734i

Symbolic Calculus

a 6.1 redefine "a" to be unitless (see above), so MathCAD isnot confused below.

f x( ) x a( )2 10 sin 2 x( )

x

d x( ) 2 x 2 a20 cos 2 x( )

x

10 sin 2 x( )

x2

x 5 4.95 5

5 0 50

50

100

150

f x( )

x

5 0 540

20

0

20

d x( )

x

Page 3: Mathcad Homework

Vector and Matrix Calculations

vx 1 vy 2

vvx

vy

v1

2

v 2.236 v v 5 magnitude and dot product

v vx i vy complex plane representation

arg v( ) 116.565 deg angle to a vector (argument)

A

1

2

0

2

1

2

3

5

3

A1

1.182

0.545

0.364

1.091

0.273

0.182

0.636

0.091

0.273

A A1

1

0

0

0

1

0

0

0

1

Programming

f x( ) x x 1if

x 1( )2

1 1 x 3if

3( ) x 3if

piecewise function

x 2 1.9 5

2 0 2 44

2

0

2

f x( )

x

Page 4: Mathcad Homework

general programming problem example: find the sum of first N numbers divisible by 3

N 10000

results i 0

n 0

total 0

i i 1

remainder mod i 3( )

total total i remainder 0=if

0 otherwise

n n 1 remainder 0=if

n Nwhile

i total( )

results 3 104

1.5 108

largest results0 0 largest 3 10

4

sum results0 1 sum 1.5 10

8

alternative solution (for this problem)

i 3 6 3 N sum

i

i sum 1.5 108

other (even better) alternative solutions (for this problem):

3

1

N

i

i

1.5 108

or 3N N 1( )

21.5 10

8

Finding roots

f x( ) 2 x2

4 sin x( ) 2

x 1 root f x( ) x( ) 1.725

x 1 root f x( ) x( ) 0.423x 1 0.9 2

1 0 1 24

2

0

2

4

0f x( )

x

marker added at 0on vertical axis

Page 5: Mathcad Homework

Solving a set of nonlinear equations

x 1 y 1 initial guess

Given

x 2 y2

=

ysin x( )

xx y=

solution Find x y( )

x solution0

x 0.252 y solution1

y 1.322

Checking results (solving symbolically and plotting)

ysin x( )

xx y=

x 2 y2

=

fb x( )sin x( )

x x 1( )

fa x( )x 2 i

x 2 i

fa x( )1

1.322 fb x( ) 1.322

x 0.01 0.05 0.5

0 0.1 0.2 0.3 0.41

1.2

1.4

1.6

1.8

2

fa x( )1

fb x( )

x

Iterative calculations with subscriptsi 1 10 x

01 y

01

xi

xi 1 2

yi

xi 1 x

i

2

x

0

0

1

2

3

4

5

6

7

1

3

5

7

9

11

13

...

y

0

0

1

2

3

4

5

6

7

1

2

4

6

8

10

12

...

Page 6: Mathcad Homework

Finding an optimal solution given constraints

x 1 y 1

z x y( ) x 1( )2

x sin y( )

Given

x 2

x 2 y2

3

3 y 5

z_max_loc Maximize z x y( )

z_max_loc2

1.571

x z_max_loc0

x 2

y z_max_loc1

y 1.571 z x y( ) 11