incr-set prlevel 1
if #0=2 START 
incr-set prlevel -1

;;; Usage:
;;; 	<from_div_powers1 f g
;;;
;;; Write a polynomial f in the divided power algebra in terms of 
;;; ordinary powers.
incr-set prlevel 1
jump END
;;;
;;; Parameters:
;;;   f = 1x1 matrix.
;;;
;;; Output values:
;;;   g = result 1x1 matrix.
;;;
;;; The monomials of f are to be interpreted as monomials in the divided 
;;; powers.  Thus if f = x2+y3z2 then f is to be interpreted 
;;; as x^(2) + y^(3) z^(2), and g = (1/2)x2+(1/12)y3z2.

; created 4/26/89 DE,MS
START:

; separate f into a row vector of monomials and a row vector of coefficients.
coef #1 @monoms @coefs !

; compute the multipliers for each monomial, and put these into a diagonal 
; matrix.
diff @monoms @monoms @multipliers
poly @zeromap 0
ev @zeromap @multipliers @multipliers
<inverse @multipliers @multipliers

; combine the multipliers with the monomials with the original coefficients.
mult @monoms @multipliers @row
transpose @coefs @coefs'
mult @row @coefs' #2

kill @monoms @coefs @multipliers @zeromap @row @coefs'
END:
incr-set prlevel -1

$;;;;;;;; EXAMPLES ;;;;;;;;;;;;;;;;;;;;;;;;;
<ring 3 xyz r
poly f x2+xy+y2               ;(x+y)^(2)
<from_div_powers1
<from_div_powers1 f g
type g
; 1/2x2+xy+1/2y2              ;This is (1/2) (x+y)^2

<to_div_powers1 g h
type h
