With some off-list help (thank you), I think defint is better than ldefint;
try this
(%i1) hilbert_transform(f) := block([t : ?gensym(), x : ?gensym(), ht],
ht : defint((f(x - t) - f(x + t))/(%pi * t),t,0,inf),
buildq([x,ht], lambda([x], ht)))$
(%i2) hilbert_transform('cos)(x);
(%o2) integrate((cos(g33340-x)-cos(g33340+x))/g33340,g33340,0,inf)/%pi
(%i3) ev(%, trigexpand, integrate);
(%o3) sin(x)
(%i4) hilbert_transform('sin)(x);
(%o4) integrate((-sin(g33848+x)-sin(g33848-x))/g33848,g33848,0,inf)/%pi
(%i5) ev(%, trigexpand, integrate);
(%o5) -cos(x)
Converting from lambda form to expression / variable form is a good
exercise; if
you need help, let us know.
Barton (who has forgotten a great deal about Weiner-Hopf factorizations,
Hilbert transforms, and the Plemelj formula.)