Nesting subroutines

Description

The following subroutine, labeled ".4", calculates the value of the expression √(x2 + y2 + z2+ t2) as part of a larger calculation in a larger program. The subroutine calls upon another subroutine (a nested subroutine), labeled ".5", to do the repetitive squaring.

The program is executed after placing the variables t, z, y, and x into the T-, Z-, Y-, and X-registers.

Example:
If you run the subroutine (with its nested subroutine) alone using x = 4.3, y = 7.9, z = 1.3, and t = 8.0, the answer you get upon pressing GSB . 4 is 12.1074.

Program Resources

Labels

Name Description
.4 Main subroutine
.5 Nested subroutine

Program

Line Display Key Sequence
000
001 42,21, .4 f LBL . 4
002 43 11 g
003 32 .5 GSB . 5
004 32 .5 GSB . 5
005 32 .5 GSB . 5
006 11 √x̅
007 43 32 g RTN
008 42,21, .5 f LBL . 5
009 34 x↔y
010 43 11 g
011 40 +
012 43 32 g RTN