



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




by First_name Last_name
Basic calculations (solution to quadratic equation: ax
2
a := 1 b := 2 c := 3
x 1
−b b
2
2 a⋅
:= x 2
−b b
2
− −4 a⋅ ⋅c
2 a⋅
x 1
= − 1 +1.414i x 2
=− 1 −1.414i
checking results:
f x( ) a x
2
:= ⋅ + b x⋅ +c
f x ( 1 )
= 0 f x ( 2 )
Plotting a function using a range variable
x := − 5 , −4.95.. 3 x
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
-4.
...
− 4 − 2 0 2
0
5
10
15
20
f x( )
x
Using units and significant digit display
m := 100 lb⋅ v := 60 mph⋅ a 20
ft
sec
2
p := m v⋅ p 1.217 10
3
×
m kg⋅
s
F := m a⋅ F =62.2 lbf⋅
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 is
not confused below.
f x( ) ( x −a)
2 10 sin 2 x(^ ⋅ )
x
d x( ) 2 x⋅ − 2 a⋅ 20
cos 2 x( ⋅ )
x
sin 2 x( ⋅ )
x
2
x :=− 5 , −4.95.. 5
− 5 0 5
0
50
100
150
f x( )
x
− 5 0 5
− 40
− 20
0
20
d x( )
x
general programming problem example: find the sum of first N numbers divisible by 3
results i ← 0
n ← 0
total ← 0
i ←i + 1
remainder ←mod i 3( , )
total total i if remainder = 0
0 otherwise
n ← n + 1 ifremainder = 0
whilen <N
( i total)
results 3 10
4
× 1.5 10
8
×
= largest results
0 0,
:= largest 3 10
4
= ×
sum results
0 1,
:= sum 1.5 10
8
= ×
alternative solution (for this problem)
i := 3 6, ..3 N⋅ sum
i
i
:= sum 1.5 10
8
= ×
other (even better) alternative solutions (for this problem):
1
N
i
i
8
= × or^3
8
= ×
Finding roots
f x( ) 2 x
2
:= ⋅ − 4 sin x⋅ ( )− 2
x := 1 root f x( ( ) x, ) =1.
x := − 1 root f x( ( ) x, ) =−0.
x :=− 1 , −0.9.. 2
− 1 0 1 2
− 4
− 2
0
2
4
f x( ) 0
x
marker added at 0
on vertical axis
Solving a set of nonlinear equations
x := 1 y := 1 initial guess
Given
x 2 y
2
= −
y
sin x( )
x
= +x y⋅
solution :=Find x y( , )
x solution
0
:= x = 0.252 y solution
1
:= y =1.
Checking results (solving symbolically and plotting)
y
sin x( )
x
= +x y⋅
x 2 y
2
= −
fb x( )
sin x( )
x ⋅(x − 1 )
fa x( )
− x − 2 ⋅i
x − 2 ⋅i
fa x( )
0
= 1.322 fb x( ) =1.
x :=0.01 0.05, ..0.
0 0.1 0.2 0.3 0.
1
2
fa x( ) 0
fb x( )
x
Iterative calculations with subscripts
i := 1 .. 10 x
0
:= 1 y
0
x
i
x
i 1−
y
i
x
i 1−
x
i
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
...