Average Error: 2.7 → 0.6
Time: 14.3s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.083751370533967347078416018295024354878 \cdot 10^{-102}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{\sin y}{y}\\ \mathbf{elif}\;z \le 3.193474315482475654610578332547852767746 \cdot 10^{-129}:\\ \;\;\;\;\frac{\frac{\sin y}{y}}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{\sin y}{y}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.083751370533967347078416018295024354878 \cdot 10^{-102}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{\sin y}{y}\\

\mathbf{elif}\;z \le 3.193474315482475654610578332547852767746 \cdot 10^{-129}:\\
\;\;\;\;\frac{\frac{\sin y}{y}}{z} \cdot x\\

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

\end{array}
double f(double x, double y, double z) {
        double r24887584 = x;
        double r24887585 = y;
        double r24887586 = sin(r24887585);
        double r24887587 = r24887586 / r24887585;
        double r24887588 = r24887584 * r24887587;
        double r24887589 = z;
        double r24887590 = r24887588 / r24887589;
        return r24887590;
}

double f(double x, double y, double z) {
        double r24887591 = z;
        double r24887592 = -1.0837513705339673e-102;
        bool r24887593 = r24887591 <= r24887592;
        double r24887594 = x;
        double r24887595 = r24887594 / r24887591;
        double r24887596 = y;
        double r24887597 = sin(r24887596);
        double r24887598 = r24887597 / r24887596;
        double r24887599 = r24887595 * r24887598;
        double r24887600 = 3.1934743154824757e-129;
        bool r24887601 = r24887591 <= r24887600;
        double r24887602 = r24887598 / r24887591;
        double r24887603 = r24887602 * r24887594;
        double r24887604 = r24887601 ? r24887603 : r24887599;
        double r24887605 = r24887593 ? r24887599 : r24887604;
        return r24887605;
}

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.6
\[\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 2 regimes
  2. if z < -1.0837513705339673e-102 or 3.1934743154824757e-129 < z

    1. Initial program 0.8

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied *-commutative0.8

      \[\leadsto \frac{\color{blue}{\frac{\sin y}{y} \cdot x}}{z}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.8

      \[\leadsto \frac{\frac{\sin y}{y} \cdot x}{\color{blue}{1 \cdot z}}\]
    6. Applied times-frac0.6

      \[\leadsto \color{blue}{\frac{\frac{\sin y}{y}}{1} \cdot \frac{x}{z}}\]
    7. Simplified0.6

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

    if -1.0837513705339673e-102 < z < 3.1934743154824757e-129

    1. Initial program 8.1

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity8.1

      \[\leadsto \frac{x \cdot \frac{\sin y}{y}}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac0.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.083751370533967347078416018295024354878 \cdot 10^{-102}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{\sin y}{y}\\ \mathbf{elif}\;z \le 3.193474315482475654610578332547852767746 \cdot 10^{-129}:\\ \;\;\;\;\frac{\frac{\sin y}{y}}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{\sin y}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 
(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))