# Error-Bounded Learned Scientific Data Compression with Preservation of Derived Quantities
## 3 The Compression Framework
### Preservation of the Derived Quantities
#### 3.2.1 Constraint Satisfaction  
QoI preservation is crucial to the XGC application, and thus, QoI errors need to be within tolerance limits after decompression. We first define a general QoI preservation problem and then apply it to the XGC application. Let \(f^{0}\) be the decompressed output from any compressor that has a bounded error on PD and \(f\) be the output that we are going to obtain after the constraint satisfaction step. We consider a general equality-constrained optimization problem [25; 26],\[ \begin{split}\text{minimize}& d\Big{(}\mathbf{f},\mathbf{f}^{0} \Big{)}\\ \text{subject to}& h(\mathbf{f})=0,\end{split}  \tag{6}\]  
where \(d\Big{(}\mathbf{f},\mathbf{f}^{0}\Big{)}\) is a distance measure between \(\mathbf{f}\) and \(\mathbf{f}^{0}\), and \(h:\mathbb{R}^{n}\rightarrow\mathbb{R}^{m}\) computes the \(m\) number of QoI that need to be preserved. This approach enables us to obtain the updated output \(\mathbf{f}\) that satisfies QoI preservation while minimizing the distance between \(\mathbf{f}\) and \(\mathbf{f}^{0}\), so that PD error can be still bounded within tolerance. The Lagrangian is  
\[\mathcal{L}(\mathbf{f},\mathbf{\lambda})=d\Big{(}\mathbf{f},\mathbf{f}^{0}\Big{)}+\mathbf{\lambda }^{T}h(\mathbf{f}), \tag{7}\]  
where \(\mathbf{\lambda}=[\lambda_{1},\dots,\lambda_{m}]\) is a Lagrange multiplier vector. For constraint satisfaction of the XGC application, we focus our attention on the four QoI--density \(n\), parallel flow \(u_{\parallel}\), perpendicular temperature \(T_{\perp}\), parallel temperature \(T_{\parallel}\) with flux surface averaged density \(n_{0}^{\alpha\pi g}\) and flux surface averaged temperature \(T_{0}^{\alpha g}\) being averages over the space. Except for density, the QoI are non-linear, and so we make several assumptions and modifications to QoI computations in Equations (1)-(4) to simplify the problem. First, we rewrite \(T_{\parallel}\) in Equation (4) to remove \(u_{\parallel}\) in the integral. Since \(\frac{\int f(x,p,t)\text{vol}(x,p)d\
u_{\perp}dv_{\parallel}}{n(x,t)}=1\), we can use \(\frac{f(x,p,t)\text{vol}(x,p)}{n(x,t)}\) as the probability density function. We will use expected value notation which considerably simplifies the development. For example,  
\[\text{E}(v_{\parallel})=\frac{\int f(x,\mathbf{v},t)\text{vol}(x,\mathbf{v})mv_{ \parallel}(\mathbf{v})dv_{\perp}dv_{\parallel}}{n(x,t)}. \tag{8}\]  
Then, \(T_{\parallel}\) can be written as follows:  
\[ \begin{split} T_{\parallel}(x,t)&=\frac{1}{2} \frac{\int f(x,\mathbf{v},t)\text{vol}(x,\mathbf{v})m\Big{(}v_{\parallel}(\mathbf{v})-u_{ \parallel}(x,t)\Big{)}^{2}dv_{\perp}dv_{\parallel}}{n(x,t)}\\ &=\frac{1}{2}\text{E}\bigg{[}m\Big{(}v_{\parallel}(\mathbf{v})-u_{ \parallel}(x,t)\Big{)}^{2}\bigg{]}\\ &=\frac{m}{2}\Big{[}\text{E}\Big{(}v_{\parallel}^{2}(\mathbf{v}) \Big{)}-u_{\parallel}(x)\text{E}\Big{(}v_{\parallel}(\mathbf{v})\Big{)}+u_{ \parallel}^{2}(x,t)\Big{]}\\ &=\frac{m}{2}\Big{[}\text{E}\Big{(}v_{\parallel}^{2}(\mathbf{v}) \Big{)}-u_{\parallel}^{2}(x,t)\Big{]},\end{split}  \tag{9}\]  
where the expected value notation \(\text{E}(\cdot)\) is deployed for the sake of convenience, and furthermore, \(\text{E}\Big{(}v_{\parallel}(\mathbf{v})\Big{)}=u_{\parallel}(x,t)\) following Equation (2). Therefore, we can eliminate \(u_{\parallel}\) from the integral in the \(T_{\parallel}\) computation. We get  
\[R_{\parallel}(x,t)=T_{\parallel}(x,t)+\frac{m}{2}u_{\parallel}^{2}(x,t)=\frac {1}{2}\frac{\int f(x,\mathbf{v},t)\text{vol}(x,\mathbf{v})mv_{\parallel}^{2}(\mathbf{v}) d\mathbf{v}_{\perp}d\mathbf{v}_{\parallel}}{n(x,t)} \tag{10}\]  
where we have defined a new derived quantity \(R_{\parallel}\):  
\[R_{\parallel}(x,t)\equiv T_{\parallel}(x,t)+\frac{m}{2}u_{\parallel}^{2}(x,t). \tag{11}\]  
Secondly, we use the true (correct) density \(n^{c}(x,t)\) of the original PD to compute the non-linear QoI, so that we can treat the density as a constant for each node \(x\), thereby making the QoI computation linear. We hence obtain the four independent constraints,  
\[