% File DIF.ALG	(c)		03/26/81	The Soft Warehouse %


FUNCTION DIF (EX1, INDET),
  WHEN EX1=INDET, 1 EXIT,
  WHEN ATOM(EX1), 0 EXIT,
  WHEN APPLY (GET(DIF,FIRST(EX1)), ARGEX(EX1))  EXIT,
  WHEN FREE(EX1,INDET), 0 EXIT,
  LIST ('DIF, EX1, INDET),
ENDFUN $

PROPERTY DIF, DEFINT, FUNCTION (EX1, EX2, EX3, EX4),
  EX4: THIRD(EX2:REST(EX2)),
  EX3: SECOND(EX2),
  DEFINT (DIF(EX1,INDET), EX2:FIRST(EX2), EX3, EX4)
    + DIF(EX4,INDET) * EVSUB(EX1,EX2,EX4)
    - DIF(EX3,INDET) * EVSUB(EX1,EX3,EX3),
ENDFUN $

PROPERTY DIF, INT, FUNCTION (EX1, EX2),
  WHEN INDET=EX2, EX1 EXIT,
  INT(DIF(EX1,INDET),EX2),
ENDFUN $

MINUSHALF: -1/2 $

PROPERTY DIF, ERF, FUNCTION (EX1),
  2 * #PI^MINUSHALF * #E^-(EX1^2) * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, ACSC, FUNCTION (EX1),
  -(EX1^-1) * (EX1^2-1)^MINUSHALF * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, ASEC, FUNCTION (EX1),
  EX1^-1 * (EX1^2-1)^MINUSHALF * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, ACOT, FUNCTION (EX1),
  -(1+EX1^2)^-1 * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, ACOS, FUNCTION (EX1),
  -(1-EX1^2)^MINUSHALF * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, ASIN, FUNCTION (EX1),
  (1-EX1^2)^MINUSHALF * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, ATAN, FUNCTION (EX1),
  (1+EX1^2)^-1 * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, CSC FUNCTION (EX1),
  -COT(EX1) * CSC(EX1) * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, SEC FUNCTION (EX1),
  TAN(EX1) * SEC(EX1) * DIF(EX1,INDET),

ENDFUN $

PROPERTY DIF, COT, FUNCTION (EX1),
  -CSC(EX1)^2 * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, TAN, FUNCTION (EX1),
  SEC(EX1)^2 * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, COS, FUNCTION (EX1),
  -SIN(EX1) * DIF(EX1,INDET),

ENDFUN $

PROPERTY DIF, SIN, FUNCTION (EX1),
  COS(EX1) * DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, LOG, FUNCTION (EX1, EX2),
  WHEN EX2 EQ #E,  DIF(EX1,INDET) / EX1  EXIT,
  DIF (LOG(EX1,#E)/LOG(EX2,#E), INDET),
ENDFUN $

PROPERTY DIF, ^, FUNCTION (EX1, EX2),
  EX1^EX2 * (LOG(EX1,#E)*DIF(EX2,INDET) + EX2*DIF(EX1,INDET)/EX1),
ENDFUN $

PROPERTY DIF, *, FUNCTION (EX1, EX2),
  EX1*DIF(EX2,INDET) + EX2*DIF(EX1,INDET),
ENDFUN $

PROPERTY DIF, +, FUNCTION (EX1, EX2),
  EX1: DIF(EX1,INDET),
  WHEN SUM (EX2),
    POP (EX2),
    LOOP
      EX1: EX1 + DIF(POP(EX2),INDET),
      WHEN EMPTY (EX2), EX1 EXIT,
    ENDLOOP EXIT,
  EX1 + DIF(EX2,INDET),
ENDFUN $

RDS() $
