%%HP:T(3)F(.);
@ RADICALS, by Michael Andrew Lowry
DIR
  SQ\->Q
    \<< SQ 8 SCI \->Q STD
    \>>
  \->RDCL
    \<< SQ 8 SCI \->Q STD DUP
      IF TYPE 9 ==
      THEN OBJ\-> DROP2 'K' STO 'J' STO
      ELSE 'J' STO 1 'K' STO
      END 1 'A' STO 1 'B' STO 1 'C' STO 1 'D' STO J PF 'A' 'C' FCTOR K PF 'B'
'D' FCTOR B.A.E.
    \>>
  FCTOR
    \<< \-> ov iv
      \<<
        WHILE DUP SIZE DUP 1 >
        REPEAT \-> j s
          \<< j 1 2 SUB OBJ\-> DROP DUP2
            IF ==
            THEN ov STO* DROP j 3
            ELSE DROP iv STO* j 2
            END s SUB
          \>>
        END DROP OBJ\->
        IF 0 \=/
        THEN iv STO*
        END
      \>>
    \>>
  SIMPL
    \<<
      IF C D / FP 0 \=/
      THEN
        IF B SQ C * D / DUP FP 0 ==
        THEN 'C' STO 1 'D' STO B SQ 'B' STO
        ELSE DROP
        END
      END
    \>>
  B.A.E.
    \<< 39 CHR
      IF A B / 1 \=/
      THEN A \->STR +
        IF B 1 \=/
        THEN 47 CHR + B \->STR +
        END 42 CHR +
      END 131 CHR +
      IF D 1 \=/
      THEN 40 CHR + C \->STR + 47 CHR + D \->STR + 41 CHR +
      ELSE C \->STR +
      END 39 CHR + OBJ\->
    \>>
  J 23
  K 13279128
  A 1
  B 2
  C 23
  D 3319782
  INFO
" * * I N F O * *
This directory
contains 4 programs:
  \->RDCL - Execute
this program It uses
the other 3 to find a
simplified radical
expression in the
form a/b*\v/(c/d) that
is == the input.
  FCTOR - Factors out
perfect squares from
the numerator &
denominator of the
fraction made by \->Q
from the square of
the input.
  SIMPL - Performs
several operations on
the result, in order
to simplify the final
expression.
 B.A.E. - completes
simplification & then
builds the alebraic
expression from the 4
variables of the
answer (A,B,C,D)."
  ORD
    \<< { \->RDCL FCTOR SIMPL B.A.E. J K A B C D INFO ORD } ORDER
    \>>
  T .633865691047
  PPAR { (-6.5,-3.1) (6.5,3.2) X 0 (0,0) FUNCTION Y }
END

