Mathcad Basics chung. Page 16. 12/27/2005. Lecture 2 Mathcad Basics. There
are three items that are crucial to step up to the next level of programming such ...
• •
!
•
#
$ %
"
& "
'
( * ,
) +" . / 0 12 + 3
' ' 5' 6' ' ' '
4 12 4 7 4 4 4
* * 3 3 3 3
1 8 ;< ;;)
2 (1 * 2 9* : 1 2 / . , +" ( *
3;=
;= 5,3/
=
3;=
;= 1 5,32 /
=5
3;=
;= 5,3(
=>
?;= 5, ( , 6
?=
;= /
) 1 "
=
" %
"
"
2 ')
" 2 ')
'@ 0 3
Mathcad Basics
" '
'
: 9 " 'A
" 1 ' '9 " " :
" " "
@ 0
9
" -
"
0
3
' '
!
" 3
" 0 -
0
!
" ;=
&
'
3
:
' ;
9
8
3
39
3
:
3"3
'@
9
B
'
i := 1 , 2 .. 5
j := −4 , −2 .. 4
x := 0 , 0.1.. 0.4
y := 1 .. 5
z := 5 .. 1
i=
j=
x=
y =
z=
1
-4
0
1
5
2
-2
0.1
2
4
3
0
0.2
3
3
4
2
0.3
4
2
5
4
0.4
5
1
" 32 ' " ' @3 0
2
9 "
C0
@
" 3
0 '@
3
9 :
"
93 3
" 0
" &9E C0 0
'D
"
1 ' '9 1 32"3 0 3
0 " 9 * @
3
&
"
8
"
&
Mathcad Basics
') H "'
3
3 1 12 '@ 2"3 3 3" EG '
"
" :
' '$ %
'
" "
" 3 "
1 3
" '
3
" " 3 FG % 0 0
" !@ I@ 8
2
3 " :
*
3
* 3
"
3"
3
0
3 :
"
3
'@ 0 "0
1 2?
1 3' - 3 E G0
"
'@ "
3
3 & 3
' -3
3
"
0 3
0
3 ;
>
ORIGIN ≡ 1 1 @"
93
!@ I@ 8' 3
& 3" :
" )
9
J
; ;=
" 1 8 "
J
% 'J
3
3
J
$ %
%
EG '
9
2
%
% 9 " '
3
2
J "3
" 0 " 9-
" :
"
% 9 "
3
'@ '
"
1
0
2 '
i := 1 .. 5
create a range variable i
vec := 1 + 0.5⋅ i
use the range variable as an index to a vector we are creating use the range variable in the equation for the vector definition
i
1.5 2
view the vector we just created
vec = 2.5 3 3.5
index a specific value inside vec
vec = 2.5 3
i =
cant view a specific value within a range vector
3
!
;
" J%
3
30 & " J%
Mathcad Basics
J %" "
:
'
K i := 1 .. 5
vec := 1 + 0.5⋅ i i
(vec i)3
value := i
value =
1.837
i
OR
2.828
1.837
value = 3.953
2.828
5.196
3.953
6.548
5.196 6.548
8
0
"
#
$
A
%
13
2E
"
3
;=
'
8 ;=
8 0
;= 1
*"
21 8 * 2
" J%
;=
;= "
inc = 0.778
1
J%
( 1* 2 , 1
T
x =
H =G
'A 0
*
;= *
E
$
?
# "
=G
2
3
-2 -1.222 -0.444
4
5
6
7
8
9
0.333
1.111
1.889
2.667
3.444
4.222
10 5
& A
3
'+
@0
5"3
0
''' ;= 5 L;=
?9L;= ( L 2 3 4 5 6 z= 3 4 5 6 7 4 5 6 7 8
8 "
"
)
3
" 9
Mathcad Basics
: L '
0
"3
0 1' '9
3
1
2 20
'
0
) J3
93 ') 'A 3 * 3
*
"3 :
3
F
0 " 09 31 " 2 =% 0 " J;= 9' '' ' %0
J 3% 90 '8 6
J% 9
'
9L
0 0 '
2
y ( t ) := 5 + 0.6t − .2⋅ t + log( sin ( t ) + 2) y ( .1) = 5.38 x := 6 + y ( 4)
y ( 30) = −156.995 2
i := 1 , 1.5.. 2.5
x = 24.443 y ( i) = 5.854 5.927 5.864 5.665
)
0
&"3 0
9
' $ % 30 0 " & 0 : " & 9 J
QuadEq ( a , b , c) :=
: ' %
"
9
1
0
0 =M
"
2
b − 4⋅ a⋅ c
−b + radical
1
ans ←
%
:
2
radical ← ans ←
0 3 J
2⋅ a
2
−b − radical
2
QuadEq solves the quadratic equation of the form a⋅ x + b ⋅ x + c = 0