function bpow, e,a


;broken power law function
;
;If the break energy is set to zero, the break is ignored and the power
;law is calculated over the full range

;normalization at Epivot is 1
;;     normalization at epivot of the single powerlaw determined
;      by  a(0).  If Epivot is gt A(1), then the total
;      bpow function will lay below this normalization point.

;a(0) - negative power law index below break
;a(1) - break energy
;a(2) - negative power law index above break
;a(3) - low energy cutoff
;a(4) - negative power law index of low energy cutoff, 1<Eco<2, default 1.5

;If the break energy is set to zero, the break is ignored and the power
;law is calculated over the full range
;

;default parameters

@function_com

apar=[fltarr(3),a_cutoff]

npar = n_elements(a)
apar(0:npar-1) = a
apar(4) =  (apar(4)>1.0) < 2.0 ;spectral slope of low energy cutoff spectrum

if (size(e))(0) eq 2 then edge_products, e, mean=em else em=e

ans = em * 0.0

if apar(1) gt 0.0 then begin
    w1=where(em le apar(1), nw1)
    if nw1 ge 1 then ans(w1) = (Epivot/em(w1))^apar(0)
    w2=where(em gt apar(1), nw2)
    if nw2 ge 1 then ans(w2) = $
       (Epivot/apar(1))^apar(0) * (apar(1)/em(w2))^apar(2)

wless = where( em lt apar(3), nless)

;EXTEND THE SPECTRUM TO LOW ENERGIES BELOW THE CUTOFF WITH A POWER-LAW OF <2
if nless ge 1 then begin
    ;
    ;what is the normalization at the cutoff energy?

    normal_eco = bpow( apar(3), apar)
    ans(wless) = normal_eco * (apar(3)/em(wless))^apar(4)
endif

endif else ans = (Epivot/em)^apar(0)


return,ans
end