I want to obtain the convolution of two discretized real functions $f$ and $g$, $$ c(t) = \int_{-\infty}^{+\infty} \mathrm{d}{x} \, f(x) \, g(t-x) \tag{1} $$ via discrete Fourier transform (DFT).
As a concrete example, let $x \in [-6, 6]$ be the $x$-axis on which the functions are defined, with
$$
f(x) = \Theta(x) \, e^{-x} ~, \\
g(x) = \Pi(x/2) ~,
$$
where $\Theta(x)$ is the Heaviside step-function and $\Pi(x)$ is the rectangular function.
Then the exact analytical expression for the convolution will be (see also figure below)
$$
C(t) =
\begin{cases}
0 , & t \leq -1 \\
1 - e^{t + 1} , & -1 < t \leq 1 \\
e^{-t} (e - e^{-1}) , & t \geq 1
\end{cases}
$$
The $x$-axis is discretized into $N = 2^K$ points. DFT (and inverse DFT) can be used to obtain the periodic (circular) convolution $c_P$ of $f$ and $g$, $$ c_P[n] = DFT^{-1} ( DFT(f) \cdot DFT(g) ) ~. $$
According to what I have seen in text-books (e.g. section 2.4 of this), the aperiodic (‘infinite’) convolution (corresponding to infinite ‘signals’ for $f$ and $g$) can be obtained by zero-padding $f$ and $g$ arrays at the end by $N-1$ zeros. Then the discretized convolution corresponding to Eq. 1 should be obtained as $$ c[n] = DFT^{-1} ( DFT(f_{padded}) \cdot DFT(g_{padded}) ) $$
I tried to do this in Python using scipy.fftpack
(see the code here). But the results of this discrete convolution does not match with the analytic one (see figure); namely, the scale and the position of the discrete convolution is not correct.
Is this the correct way to perform the discrete (infinite) convolution of $f$ and $g$?
*Note: The correct result is actually obtained by padding $f$ by $N-1$ zeros at the end, re-arranging (center-padding) $g$ as $\hat{g} := (g_{+} ~|~ N-1 ~ \text{zeros} ~|~ g_{-})$, where $g_{\pm}$ denotes the right/left half of $g$, and applying DFT as $$ c[n] = DFT^{-1} ( DFT(f_{padded}) \cdot DFT(\hat{g}) ) ~; $$ finally one should divide elements of $c$ by $\sum_{i} g_i$. But I cannot understand the reason behind this.