Free Definition Of Function .... Def Fn - Sharp MZ-80A Owner's Manual

Hide thumbs Also See for MZ-80A:
Table of Contents

Advertisement

28
Free
Definition of Function
.....
DEF FN
Various functions
have been
described,
and
here is
an
explanation of DEF FN defined
as
a new function combining
such various
functions. Some
definition examples are listed below:
DEF FNA
(X)
=
2
*
X
t
2
+
3
*
X
+
1
. .
.....
2XJ
+ 3X + I
is
defined as
FNA
(X).
DEF FNB
(X)
=
SIN
(X)
t
2 + COS (X)
t
2
_ _ _ _
sin2
X
+
cos2
X
is
defined as FNB (X) this
is always 1
.
DEF
FNE(V)
=
1/2
*
M
*
V
t 2
..........
1/2MV2
is defined
as FNE
(V).
DEF
represents
"define". New functions
are named with
FN suffixed.
X or V in the parenthesis
is called the
argument. For
example, the third function
(seems
to
be motion energy)
is
used.
10 DEFFNE(V)=
1/2*
M *V 1 2
20 M
=
5.5 :
V
=
3.5
30 PRINT FNE (V), FNE (V
*
2),
FNE
(V
*
3)
40
END
Motion energy
at
initial velocity V and
motion
energy
with
velocity doubled or tripled
are
displayed. DEF FN
command is very convenient particulary when the
same
functions
are
often
used in a
long program.
Fall from an altitude of
10,000
meters!
How do you think the velocity
and altitude
of
a fall
from
an altitude of 10,000
meters
changes
per second?
Fuction FNV (T)
in the
program
is
the fall velocity after
a lapse of
time
T, and
FNH (T)
is the
altitude
at
the same
time.
Acceleration
of
gravity
G.
atornospheric resistance
factor
K and altitude H when a fall occurs are assigned by line
number
20.
10 ?"
3
"
:
T
=
0
20 G
=
9.8 :K
=
0.15
:H= 10000
30
DEF
FNV (T)
=
G/K
*
(1
EXP (- K
*
T))
40 DEF
FNH (T)
=
H
-
FNV (T)
*
T
50
?
"
ffi
"
60
PRINT
"TIME
T
:
MUSIC
"
+
A0"
......
Instruction with
beep
to
be
explained on page
76.
70
PRINT "VELOCITY"
;
FNV (T)
80
PRINT "ALTITUDE"
;
FNH (T)
90 T
=
T
+
1 :
GOTO 50
...................
This is a shift instruction for the program
to
be shifted
to line
No. 50.
a
and
d
are
entered with the
CLR
1
HOME
key pressing in the graphic mode.

Advertisement

Table of Contents
loading

Table of Contents