|
@@ -67,7 +67,7 @@ While the [[id:f3e3cdb9-a661-4598-8be1-e15f587f35bb][Introduction]] describes th
|
|
#+TOC: headlines 3
|
|
#+TOC: headlines 3
|
|
#+TOC: listings
|
|
#+TOC: listings
|
|
|
|
|
|
-* WORKING Expression Types [2/4]
|
|
|
|
|
|
+* WORKING Expression Types [1/4]
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: fe611e8f-db42-4fe0-8e77-9cfb55d2227c
|
|
:ID: fe611e8f-db42-4fe0-8e77-9cfb55d2227c
|
|
:END:
|
|
:END:
|
|
@@ -108,7 +108,10 @@ Note, by default, ~eqal~ will handle ~type-error~ by trying to switch the order
|
|
(defgeneric evaluate (expression &key substitutions-list resolve-constants-light-p resolve-constants-hard-p))
|
|
(defgeneric evaluate (expression &key substitutions-list resolve-constants-light-p resolve-constants-hard-p))
|
|
|
|
|
|
@export
|
|
@export
|
|
- (defgeneric simplify (expression &key resolve-constans-light-p resolve-constants-hard-p))
|
|
|
|
|
|
+ (defgeneric simplify (expression &key resolve-constants-light-p resolve-constants-hard-p))
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defgeneric to-sexp (expression &optional resolve-constants-p))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
#+Caption: Types
|
|
#+Caption: Types
|
|
@@ -183,7 +186,7 @@ Of the various types, there are three atomic types, ~<number>~, ~<variable>~ and
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
*** DONE Numbers
|
|
*** DONE Numbers
|
|
-CLOSED: [2019-01-05 Sat 09:56]
|
|
|
|
|
|
+CLOSED: [2019-01-16 Wed 16:01]
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: f0314608-46d9-4cc0-a3e1-897481827ddf
|
|
:ID: f0314608-46d9-4cc0-a3e1-897481827ddf
|
|
:END:
|
|
:END:
|
|
@@ -204,10 +207,14 @@ As an ~<atomic>~, ~<number>~ is rather simple, having only one slot, ~value~, re
|
|
|
|
|
|
(defmethod eqal ((expression-a <number>) (expression-b <number>))
|
|
(defmethod eqal ((expression-a <number>) (expression-b <number>))
|
|
(= (value expression-a) (value expression-b)))
|
|
(= (value expression-a) (value expression-b)))
|
|
|
|
+
|
|
|
|
+ (defmethod to-sexp ((expression <number>) &optional resolve-constants-p)
|
|
|
|
+ (declare (ignorable resolve-constants-p))
|
|
|
|
+ (slot-value expression 'value))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
*** DONE Variables
|
|
*** DONE Variables
|
|
-CLOSED: [2019-01-05 Sat 09:56]
|
|
|
|
|
|
+CLOSED: [2019-01-16 Wed 16:13]
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: f5f656d0-6253-4c4c-8c50-6622d685eaa1
|
|
:ID: f5f656d0-6253-4c4c-8c50-6622d685eaa1
|
|
:END:
|
|
:END:
|
|
@@ -229,10 +236,14 @@ CLOSED: [2019-01-05 Sat 09:56]
|
|
(defmethod eqal ((expression-a <variable>) (expression-b <variable>))
|
|
(defmethod eqal ((expression-a <variable>) (expression-b <variable>))
|
|
(equalp (value expression-a)
|
|
(equalp (value expression-a)
|
|
(value expression-b)))
|
|
(value expression-b)))
|
|
|
|
+
|
|
|
|
+ (defmethod to-sexp ((expression <variable>) &optional resolve-constants-p)
|
|
|
|
+ (declare (ignore resolve-constants-p))
|
|
|
|
+ (slot-value expression 'name))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
*** DONE Constants
|
|
*** DONE Constants
|
|
-CLOSED: [2019-01-05 Sat 12:07]
|
|
|
|
|
|
+CLOSED: [2019-01-16 Wed 16:23]
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: 806bbce0-ab52-411a-8178-29bda6bbb36a
|
|
:ID: 806bbce0-ab52-411a-8178-29bda6bbb36a
|
|
:END:
|
|
:END:
|
|
@@ -271,9 +282,14 @@ Equality of constants is a bit different, and is checked as follows:
|
|
(defmethod eqal ((expression-a <constant>) (expression-b <number>))
|
|
(defmethod eqal ((expression-a <constant>) (expression-b <number>))
|
|
(= (slot-value expression-a 'value)
|
|
(= (slot-value expression-a 'value)
|
|
(slot-value expression-b 'value)))
|
|
(slot-value expression-b 'value)))
|
|
|
|
+
|
|
|
|
+ (defmethod to-sexp ((expression <constant>) &optional resolve-constants-p)
|
|
|
|
+ (if resolve-constants-p
|
|
|
|
+ (slot-value expression 'value)
|
|
|
|
+ (slot-value expression 'name)))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-** WORKING Compound Types [6/7]
|
|
|
|
|
|
+** WORKING Compound Types [0/7]
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: a0d2eb19-8a1e-4dee-9b41-c454a49cacc4
|
|
:ID: a0d2eb19-8a1e-4dee-9b41-c454a49cacc4
|
|
:END:
|
|
:END:
|
|
@@ -291,8 +307,7 @@ Compound types are the majority of expressions. An atom is well and good, but o
|
|
nil)
|
|
nil)
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** DONE Additions
|
|
|
|
-CLOSED: [2019-01-05 Sat 16:00]
|
|
|
|
|
|
+*** WORKING Additions
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: a1a01fb4-59e1-4459-9ab9-d32269af77dd
|
|
:ID: a1a01fb4-59e1-4459-9ab9-d32269af77dd
|
|
:END:
|
|
:END:
|
|
@@ -317,8 +332,7 @@ CLOSED: [2019-01-05 Sat 16:00]
|
|
:test #'eqal)))))
|
|
:test #'eqal)))))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** DONE Subtractions
|
|
|
|
-CLOSED: [2019-01-05 Sat 16:41]
|
|
|
|
|
|
+*** WORKING Subtractions
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: aad16971-81c8-48da-aaa5-bb84b03d6912
|
|
:ID: aad16971-81c8-48da-aaa5-bb84b03d6912
|
|
:END:
|
|
:END:
|
|
@@ -345,8 +359,7 @@ Subtractions again, contain only a list of terms. However, unlike other types h
|
|
((or (not keep) (null a) (null b)) keep)))))
|
|
((or (not keep) (null a) (null b)) keep)))))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** DONE Multiplications
|
|
|
|
-CLOSED: [2019-01-05 Sat 12:17]
|
|
|
|
|
|
+*** WORKING Multiplications
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: 0c601f5c-a614-4c30-9107-220a5d45a334
|
|
:ID: 0c601f5c-a614-4c30-9107-220a5d45a334
|
|
:END:
|
|
:END:
|
|
@@ -369,8 +382,7 @@ Multiplication is one of the more frequently used expression types, and is, surp
|
|
:test #'eqal))))
|
|
:test #'eqal))))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** DONE Divisions
|
|
|
|
-CLOSED: [2019-01-05 Sat 12:25]
|
|
|
|
|
|
+*** WORKING Divisions
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: bcc56ff0-0a6f-4eb6-8185-2cab3eed99da
|
|
:ID: bcc56ff0-0a6f-4eb6-8185-2cab3eed99da
|
|
:END:
|
|
:END:
|
|
@@ -396,8 +408,7 @@ Division is similar to ~<multiplication>~, although instead of having ~terms~ it
|
|
(div-denominator expression-b))))
|
|
(div-denominator expression-b))))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** DONE Exponentials
|
|
|
|
-CLOSED: [2019-01-05 Sat 15:28]
|
|
|
|
|
|
+*** WORKING Exponentials
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: d8c87457-5c3b-4263-ba60-53b9b9f5e816
|
|
:ID: d8c87457-5c3b-4263-ba60-53b9b9f5e816
|
|
:END:
|
|
:END:
|
|
@@ -434,8 +445,7 @@ There are two primary forms of exponential -- the natural (~exp~) and the genera
|
|
:value 2.71828))
|
|
:value 2.71828))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** DONE Logarithmics
|
|
|
|
-CLOSED: [2019-01-05 Sat 15:47]
|
|
|
|
|
|
+*** WORKING Logarithmics
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: 7d4a23af-6c6b-4ae3-a8af-e477cbee9082
|
|
:ID: 7d4a23af-6c6b-4ae3-a8af-e477cbee9082
|
|
:END:
|
|
:END:
|
|
@@ -472,10 +482,108 @@ CLOSED: [2019-01-05 Sat 15:47]
|
|
(log-of expression-b))))
|
|
(log-of expression-b))))
|
|
#+END_SRC
|
|
#+END_SRC
|
|
|
|
|
|
-*** TODO Trigonometric
|
|
|
|
|
|
+*** WORKING Trigonometric
|
|
|
|
+:PROPERTIES:
|
|
|
|
+:ID: adbef278-121d-4ef4-a607-7fc129d4d6ea
|
|
|
|
+:END:
|
|
|
|
+
|
|
|
|
+Trigonemtric functions are also a bit weird -- as given a "normal" trig function, /e.g.,/ $\sin{\theta}$, there's the normal, the inverse, the hyperbolic, and the hyperbolic inverse. As such, we have a superclass for each, and then equality, which checks type and ~eqal~-ness of the inner expression.
|
|
|
|
+
|
|
|
|
+#+Caption: Trig Bases
|
|
|
|
+#+Name: type-trigs
|
|
|
|
+#+BEGIN_SRC lisp
|
|
|
|
+ @export
|
|
|
|
+ (defclass <trig> (<expression>)
|
|
|
|
+ ((expression :reader expression
|
|
|
|
+ :initarg :expression
|
|
|
|
+ :type <expression>)))
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <inverse-trig> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <hyperbolic-trig> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ (defmethod eqal ((expression-a <trig>) (expression-b <trig>))
|
|
|
|
+ (and (equalp (type-of expression-a)
|
|
|
|
+ (type-of expression-b))
|
|
|
|
+ (eqal (expression expression-a)
|
|
|
|
+ (expression expression-b))))
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <sin> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <cos> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <tan> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <csc> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <sec> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <cot> (<trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <asin> (<inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <acos> (<inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <atan> (<inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <acsc> (<inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <asec> (<inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <acot> (<inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <sinh> (<hyperbolic-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <cosh> (<hyperbolic-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <tanh> (<hyperbolic-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <csch> (<hyperbolic-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <sech> (<hyperbolic-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <coth> (<hyperbolic-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <asinh> (<hyperbolic-trig> <inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <acosh> (<hyperbolic-trig> <inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <atanh> (<hyperbolic-trig> <inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <acsch> (<hyperbolic-trig> <inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <asech> (<hyperbolic-trig> <inverse-trig>) ())
|
|
|
|
+
|
|
|
|
+ @export
|
|
|
|
+ (defclass <acoth> (<hyperbolic-trig> <inverse-trig>) ())
|
|
|
|
+#+END_SRC
|
|
|
|
|
|
-** DONE Blended Types -- Polynomial Terms
|
|
|
|
-CLOSED: [2019-01-05 Sat 09:46]
|
|
|
|
|
|
+** WORKING Blended Types -- Polynomial Terms
|
|
:PROPERTIES:
|
|
:PROPERTIES:
|
|
:ID: a7258c20-bdd1-4565-9ada-41026ea5e1a0
|
|
:ID: a7258c20-bdd1-4565-9ada-41026ea5e1a0
|
|
:END:
|
|
:END:
|
|
@@ -1382,6 +1490,7 @@ As all of the packages are defined centrally, this makes resolving inter-package
|
|
<<type-division>>
|
|
<<type-division>>
|
|
<<type-exponentials>>
|
|
<<type-exponentials>>
|
|
<<type-logarithmics>>
|
|
<<type-logarithmics>>
|
|
|
|
+ <<type-trigs>>
|
|
|
|
|
|
<<type-poly-term>>
|
|
<<type-poly-term>>
|
|
#+END_SRC
|
|
#+END_SRC
|