home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / pdprolog / dif.pro < prev    next >
Text File  |  1986-05-05  |  640b  |  25 lines

  1. /* 
  2. This program performs symbolic differentiation. 
  3.  
  4. Sample forms to differentiate:
  5.  
  6.   ?-d(x+1,x,X).
  7.   ?-d(x*x-2,x,X).
  8.  
  9. See C & M for more on this. 
  10. */
  11.  
  12.  
  13. ?-op( 9, fx, '%' ).
  14.  
  15. d(X,X,1) :- !.
  16. d(C,X,0) :- atomic(C).
  17. d(%U, X, %A) :- d( U, X, A ).
  18. d( U+V, X, A+B) :- d(U,X,A), d(V,X,B).
  19. d( U-V, X, A-B ) :- d(U,X,A), d(V,X,B).
  20. d(C*U,X,C*A) :- atomic(C), C \= X, d(U,X,A), !.
  21. d(U*V,X,B*U+A*V) :- d(U,X,A), d(V,X,B).
  22. d(U/V,X,A) :- d(U*V**(%1),X,A).
  23. d(U**V,X,V*W*U**(V-1)) :- atomic(V), c \= X, d(U,X,W).
  24. d(log(U),X,A*U**(%1)) :- d(U,X,A).
  25.