jhddiff.red 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. MODULE JHDDIFF;
  2. % Author: James H. Davenport.
  3. % Differentiation routines for algebraic expressions;
  4. SYMBOLIC PROCEDURE !*DIFFSQ(U,V);
  5. %U is a standard quotient, V a kernel.
  6. %Value is the standard quotient derivative of U wrt V.
  7. %Algorithm: df(x/y,z)= (x'-(x/y)*y')/y;
  8. !*MULTSQ(!*ADDSQ(!*DIFFF(NUMR U,V),
  9. NEGSQ !*MULTSQ(U,!*DIFFF(DENR U,V))),
  10. 1 ./ DENR U);
  11. SYMBOLIC PROCEDURE !*DIFFF(U,V);
  12. %U is a standard form, V a kernel.
  13. %Value is the standard quotient derivative of U wrt V;
  14. IF DOMAINP U THEN NIL ./ 1
  15. ELSE !*ADDSQ(!*ADDSQ(MULTPQ(LPOW U,!*DIFFF(LC U,V)),
  16. !*MULTSQ(LC U ./ 1,!*DIFFP(LPOW U,V))),
  17. !*DIFFF(RED U,V));
  18. SYMBOLIC PROCEDURE !*DIFFP(U,V);
  19. % Special treatment of SQRT's (JHD is not sure why,
  20. % but it seems to be necessary);
  21. IF ATOM (CAR U) THEN DIFFP(U,V)
  22. ELSE IF NOT(CAAR U EQ 'SQRT) THEN DIFFP(U,V)
  23. ELSE BEGIN
  24. SCALAR W,DW;
  25. W:=SIMP ARGOF CAR U;
  26. DW:= !*DIFFSQ(W,V);
  27. IF NULL NUMR DW THEN RETURN DW;
  28. RETURN !*MULTSQ(!*MULTSQ(DW,INVSQ W),
  29. !*MULTF(CDR U,MKSP(CAR U,1) .* 1 .+ NIL)./ 2)
  30. END;
  31. ENDMODULE;
  32. END;