|
From: Barton W. <wi...@un...> - 2016-03-10 13:35:30
|
Stavros suggested to me that to_poly_solve should be extended to handle equations that are linear in exp(X), but not explicitly so; for example exp(x) + exp(x + 1)= 1.
The simple way to do this, of course, is to do exp(x + 1) --> exp(x) * exp(1) at the top-level of to_poly. But exp(x) * exp(1) automatically simplifies to exp(x + 1), so it's not so easy. I considered several ways to circumvent the automatic simplification--one possibility is to use labeled boxes. I don't have much (any?) experience with labeled boxes, so if you all have insights, let me know.
Here are two functions that would do this. The function boxify-mepxt does x^(a+b) -> box(x^a, tbox) * box(x^b, tbox) and the function if-deboxify removes boxes with a given label.
These functions could be just as well be written in Maxima, but to_poly is written in CL, so I wrote them in CL.
;; x^(a+b+...) -> box(x^a, tbox) * box(x^b, tbox) * ... This provides a workaround for the automatic
;; simplification x^a * x^b --> x^(a+b).
(defun boxify-mepxt (p tbox)
(maxima-substitute #'(lambda (a b)
(setq b ($expand b))
(if (mplusp b)
(reduce 'mul (mapcar
#'(lambda (s) (take '(mlabox) (take '(mexpt) a s) tbox)) (margs b)))
(take '(mlabox) (take '(mexpt) a b) tbox))) 'mexpt p))
;; remove a box if the label is tbox (temporary box)
(defun if-deboxify (e tbox)
(maxima-substitute #'(lambda (x z) (if (eq z tbox) x (take '(mlabox) x z))) 'mlabox e))
And of course, if you all have suggestions for to_poly_solve, send me a note.
--Barton
|