Average Error: 2.6 → 0.7
Time: 15.7s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \le -4.138919433006754025982245522415293926484 \cdot 10^{-256} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.400486339854651017904177681522389558513 \cdot 10^{-313}\right):\\ \;\;\;\;\left(x \cdot \frac{\sin y}{y}\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot \sin y}{y}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot \frac{\sin y}{y} \le -4.138919433006754025982245522415293926484 \cdot 10^{-256} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.400486339854651017904177681522389558513 \cdot 10^{-313}\right):\\
\;\;\;\;\left(x \cdot \frac{\sin y}{y}\right) \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r337161 = x;
        double r337162 = y;
        double r337163 = sin(r337162);
        double r337164 = r337163 / r337162;
        double r337165 = r337161 * r337164;
        double r337166 = z;
        double r337167 = r337165 / r337166;
        return r337167;
}

double f(double x, double y, double z) {
        double r337168 = x;
        double r337169 = y;
        double r337170 = sin(r337169);
        double r337171 = r337170 / r337169;
        double r337172 = r337168 * r337171;
        double r337173 = -4.138919433006754e-256;
        bool r337174 = r337172 <= r337173;
        double r337175 = 2.4004863398547e-313;
        bool r337176 = r337172 <= r337175;
        double r337177 = !r337176;
        bool r337178 = r337174 || r337177;
        double r337179 = 1.0;
        double r337180 = z;
        double r337181 = r337179 / r337180;
        double r337182 = r337172 * r337181;
        double r337183 = r337168 / r337180;
        double r337184 = r337183 * r337170;
        double r337185 = r337184 / r337169;
        double r337186 = r337178 ? r337182 : r337185;
        return r337186;
}

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.6
Target0.3
Herbie0.7
\[\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 (* x (/ (sin y) y)) < -4.138919433006754e-256 or 2.4004863398547e-313 < (* x (/ (sin y) y))

    1. Initial program 0.2

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied div-inv0.4

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

    if -4.138919433006754e-256 < (* x (/ (sin y) y)) < 2.4004863398547e-313

    1. Initial program 13.6

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied div-inv13.6

      \[\leadsto \color{blue}{\left(x \cdot \frac{\sin y}{y}\right) \cdot \frac{1}{z}}\]
    4. Using strategy rm
    5. Applied associate-*r/17.8

      \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y}} \cdot \frac{1}{z}\]
    6. Applied associate-*l/4.4

      \[\leadsto \color{blue}{\frac{\left(x \cdot \sin y\right) \cdot \frac{1}{z}}{y}}\]
    7. Simplified2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \le -4.138919433006754025982245522415293926484 \cdot 10^{-256} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.400486339854651017904177681522389558513 \cdot 10^{-313}\right):\\ \;\;\;\;\left(x \cdot \frac{\sin y}{y}\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot \sin y}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 
(FPCore (x y z)
  :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< z -4.21737202034271466e-29) (/ (* x (/ 1 (/ y (sin y)))) z) (if (< z 4.44670236911381103e64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1 (/ y (sin y)))) z)))

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