|
From: Robert D. <rob...@gm...> - 2025-04-29 06:27:26
|
Eduardo, I'm not sure if you've already solved this problem, but if not,
maybe this is helpful.
Here's a display for the way antiderivatives are often evaluated in
elementary calculus classes. I'm guessing that's why you were looking at
at-like expressions.
(%i2) load ("dim-antideriv.lisp");
(%o2) dim-antideriv.lisp
(%i3) 'antideriv (F(u), u, a, b);
│u = b
(%o3) F(u)│
│u = a
(%i4) 'antideriv (F(u[k]), u[k], a[k], b[k]);
│u = b
(%o4) F(u )│ k k
k │
│u = a
k k
(%i5) 'antideriv(a+b,u,z^2^n+y[k],x^2-z[k]);
2
│u = x - z
(%o5) b + a│ k
│ n
│ 2
│u = z + y
k
(%i6) 'antideriv(a+b,u,z^2^n+y[k],x^2-z[k[l[u]]]);
2
│u = x - z
│ k
│ l
(%o6) b + a│ u
│ n
│ 2
│u = z + y
k
The code shown in the PS is adapted from DIM-%AT with some modifications. I
tried to make it clearer but it is still fairly obtuse. The tricky part was
getting the subexpressions to line up correctly ... it took quite a number
of tries to get it all straightened out.
Hope this helps, if not I'll give it another try.
Robert
PS.
;; DIM-%ANTIDERIV -- 2-d pretty printer display for antiderivative-like
expressions
;; copyright 2025 by Robert Dodier
;; I release this work under terms of the GNU General Public License, v2
(defun dim-%antideriv (form result)
(unless (= (length (cdr form)) 4)
(return-from dim-%antideriv (dimension-function form result)))
(let*
((args (rest form))
(expr (first args))
(my-var (second args))
(lower-val (third args))
(upper-val (fourth args))
(lower-eqn (list '(mequal) my-var lower-val))
(upper-eqn (list '(mequal) my-var upper-val))
(vertical-bar-char (if (display2d-unicode-enabled) at-char-unicode
(car (coerce $absboxchar 'list))))
vertical-bar
expr-result lower-result upper-result
expr-w expr-h expr-d lower-w lower-h lower-d upper-w upper-h upper-d)
(declare (ignorable expr-w expr-h expr-d lower-w lower-h lower-d
upper-w upper-h upper-d))
(setq expr-result (dimension expr nil 'mparen 'mparen nil 0)
expr-w width expr-h height expr-d depth)
(setq lower-result (dimension-infix lower-eqn nil)
lower-w width lower-h height lower-d depth)
(setq upper-result (dimension-infix upper-eqn nil)
upper-w width upper-h height upper-d depth)
(setq vertical-bar (list 'd-vbar (1+ (max expr-h upper-d)) (max (1+
expr-d) lower-h) vertical-bar-char))
(setq result (append (list (append (list (- lower-w) (max expr-h
upper-d)) upper-result)
(append (list 0 (- (max (1+ expr-d)
lower-h))) lower-result)
vertical-bar
(append (list 0 0) expr-result))
result))
(setq height (+ 1 (max expr-h upper-d) upper-h)
depth (+ (max (1+ expr-d) lower-h) lower-d))
(update-heights height depth)
result))
(setf (get '%antideriv 'dimension) 'dim-%antideriv)
|