Commodore 2001-8 User Manual page 48

Table of Contents

Advertisement

HYPERBOLIC COSECANT, COSH(X)
DEF FNM(X)
~
2JEXP(X) - EXP( -X))
FOR X<
>
0
HYPERBOLIC COTANGENT, COTH(X)
DEF FNN(X): EXP( - X)I(EXP (X)+EXP (-X) ) *2+1
FORX<
>
0
INVERSE HYPERBOLIC SINE, ARCSINH(X)
DEF FNO(X)
~
LOG(X + SQR(X'X + 1))
FOR ANY X
INVERSE HYPERBOLIC COSINE, ARCCOSH(X)
DEF FNP(X): LOG(X + SQR(X'X -1))
FOR X
> :
1
INVERSE HYPERBOLIC TANGENT, ARCTANH(X)
DEF FNQ(X): LOG((1 + X)I(l - X))12
FOR ABS(X) < 1
INVERSE HTPERBOLIC SECANT, ARCSECH(X)
DEF FNA(X): LOG«(SQR( - X'X + 1) + 1)IX)
FOR 0 < X < : 1
INVERSE HYPERBOLIC COSECANT, ARCCOSH(X)
DEF FNS(X): LOG«(SGN(X)'SQR(X'X + 1) + l)IX)
FOR X <
>
0
INVERSE HYPERBOLIC COTANGENT, ARCCOTH(X)
DEF FNT(X)= LOG«(X + 1)I(X - 1))12
FOR ABS(X)
>
1
GOSUB·RETURN
We have seen how to use the DEf FN to create a single variable function which can be used like any
intrinsic function. The major limitation of DEF FN is that it can consist of only a single algebraic
expression and
it
must fit on one line.
Often several lines of code will be repeated through a program. These program lines can be collected in
one place and executed by
a
GOSUB command:
GOSUB 5000
The lines of code are called a subroutine. GQSUB means go to the subroutine. It differs from GOTO in
that GOSUB remembers at which line number
it
was executing before the GOSUB and can return
automatically to the following line after executing the subroutine code.
A subroutine is stored as a series of lines in BASIC starting at the line number specified by the GOSUB.
The last line of the subroutine must be a RETURN statement. This tells BASIC you want to resume
executing the mainline code after the GOSUB.
44
I

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents