Average Error: 2.7 → 0.2
Time: 14.3s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.336233976126022862858460049675672066239 \cdot 10^{-18}:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin y \cdot \frac{1}{y}\right)\right) \cdot x}{z}\\ \mathbf{elif}\;z \le 393164264.75852668285369873046875:\\ \;\;\;\;\frac{x}{\frac{z}{\sin y} \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -2.336233976126022862858460049675672066239 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin y \cdot \frac{1}{y}\right)\right) \cdot x}{z}\\

\mathbf{elif}\;z \le 393164264.75852668285369873046875:\\
\;\;\;\;\frac{x}{\frac{z}{\sin y} \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\

\end{array}
double f(double x, double y, double z) {
        double r418593 = x;
        double r418594 = y;
        double r418595 = sin(r418594);
        double r418596 = r418595 / r418594;
        double r418597 = r418593 * r418596;
        double r418598 = z;
        double r418599 = r418597 / r418598;
        return r418599;
}

double f(double x, double y, double z) {
        double r418600 = z;
        double r418601 = -2.336233976126023e-18;
        bool r418602 = r418600 <= r418601;
        double r418603 = y;
        double r418604 = sin(r418603);
        double r418605 = 1.0;
        double r418606 = r418605 / r418603;
        double r418607 = r418604 * r418606;
        double r418608 = log1p(r418607);
        double r418609 = expm1(r418608);
        double r418610 = x;
        double r418611 = r418609 * r418610;
        double r418612 = r418611 / r418600;
        double r418613 = 393164264.7585267;
        bool r418614 = r418600 <= r418613;
        double r418615 = r418600 / r418604;
        double r418616 = r418615 * r418603;
        double r418617 = r418610 / r418616;
        double r418618 = r418603 / r418604;
        double r418619 = r418605 / r418618;
        double r418620 = r418610 * r418619;
        double r418621 = r418620 / r418600;
        double r418622 = r418614 ? r418617 : r418621;
        double r418623 = r418602 ? r418612 : r418622;
        return r418623;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.7
Target0.3
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;z \lt -4.217372020342714661850238929213415773451 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \cdot 10^{64}:\\ \;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -2.336233976126023e-18

    1. Initial program 0.1

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied clear-num0.1

      \[\leadsto \frac{x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}\]
    4. Using strategy rm
    5. Applied expm1-log1p-u0.1

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\frac{y}{\sin y}}\right)\right)}}{z}\]
    6. Simplified0.1

      \[\leadsto \frac{x \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\frac{1}{y} \cdot \sin y\right)}\right)}{z}\]

    if -2.336233976126023e-18 < z < 393164264.7585267

    1. Initial program 6.0

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*0.2

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}\]
    4. Simplified0.3

      \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{z}{\sin y}}}\]

    if 393164264.7585267 < z

    1. Initial program 0.1

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied clear-num0.2

      \[\leadsto \frac{x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.336233976126022862858460049675672066239 \cdot 10^{-18}:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin y \cdot \frac{1}{y}\right)\right) \cdot x}{z}\\ \mathbf{elif}\;z \le 393164264.75852668285369873046875:\\ \;\;\;\;\frac{x}{\frac{z}{\sin y} \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"

  :herbie-target
  (if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))

  (/ (* x (/ (sin y) y)) z))