[lisplab-cvs] r70 - src/core

Jørn Inge Vestgården jivestgarden at common-lisp.net
Sat Aug 8 11:49:42 UTC 2009


Author: jivestgarden
Date: Sat Aug  8 07:49:41 2009
New Revision: 70

Log:
tria and error on symbolic expressions

Modified:
   src/core/level0-expression.lisp

Modified: src/core/level0-expression.lisp
==============================================================================
--- src/core/level0-expression.lisp	(original)
+++ src/core/level0-expression.lisp	Sat Aug  8 07:49:41 2009
@@ -99,5 +99,38 @@
 (def-sym-expr-method .sub .-)
 (def-sym-expr-method .expt .^)
 
+;;;; Then the derivatives
 
+(defmethod .= ((x symbol) (y symbol) &optional whatever)
+  (eql x y))
+
+(defmethod .log ((x symbol) &optional (n nil))
+  (if x
+      (expr '.log x n)
+      (expr '.log x)))
+
+(defgeneric .partial (epxr var)
+  (:documentation "Parial derivative of the expressions with regards to the variable."))
+
+(defmethod .partial ((x symbol) (y symbol))
+  (if (eql x y)
+      1
+      0))
+
+(defmethod .partial ((x expression) (y symbol)))
+
+(defgeneric .partial-of-function (fun arg-num args)
+  (:documentation "The parial derivive of a function"))
+
+(defmethod .partial-of-function ((f (eql '.log)) (arg-num (eql 0)) args)
+  "Args must be a list"
+  (if (cdr args)
+      (expr './ 1 (car args) (.log (cadr args)))
+      (expr './ (car args))))
+
+(defmethod .partial-of-function ((f (eql '.sin)) (arg-num (eql 0)) args)
+  (expr '.cos (car args)))
+
+(defmethod .partial-of-function ((f (eql '.cos)) (arg-num (eql 0)) args)
+  (expr '.- (expr '.sin (car args))))
 




More information about the lisplab-cvs mailing list