Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ fmod() [8/10]

var stan::math::fmod ( const var a,
const var b 
)
inline

Return the floating point remainder after dividing the first variable by the second (cmath).

The partial derivatives with respect to the variables are defined everywhere but where \(x = y\), but we set these to match other values, with

\(\frac{\partial}{\partial x} \mbox{fmod}(x, y) = 1\), and

\(\frac{\partial}{\partial y} \mbox{fmod}(x, y) = -\lfloor \frac{x}{y} \rfloor\).

\[ \mbox{fmod}(x, y) = \begin{cases} x - \lfloor \frac{x}{y}\rfloor y & \mbox{if } -\infty\leq x, y \leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{fmod}(x, y)}{\partial x} = \begin{cases} 1 & \mbox{if } -\infty\leq x, y\leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{fmod}(x, y)}{\partial y} = \begin{cases} -\lfloor \frac{x}{y}\rfloor & \mbox{if } -\infty\leq x, y\leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

Parameters
aFirst variable.
bSecond variable.
Returns
Floating pointer remainder of dividing the first variable by the second.

Definition at line 101 of file fmod.hpp.