Analytic Solutions to Z and X

no for loop
cumsum for integral part of solution