Average Error: 2.8 → 0.5
Time: 14.2s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.558037767913342817643933364747126420158 \cdot 10^{92} \lor \neg \left(z \le 5.039220706859192027751049543236769960828 \cdot 10^{68}\right):\\ \;\;\;\;\frac{x}{\frac{y}{\sin y}} \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.558037767913342817643933364747126420158 \cdot 10^{92} \lor \neg \left(z \le 5.039220706859192027751049543236769960828 \cdot 10^{68}\right):\\
\;\;\;\;\frac{x}{\frac{y}{\sin y}} \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r333216 = x;
        double r333217 = y;
        double r333218 = sin(r333217);
        double r333219 = r333218 / r333217;
        double r333220 = r333216 * r333219;
        double r333221 = z;
        double r333222 = r333220 / r333221;
        return r333222;
}

double f(double x, double y, double z) {
        double r333223 = z;
        double r333224 = -1.5580377679133428e+92;
        bool r333225 = r333223 <= r333224;
        double r333226 = 5.039220706859192e+68;
        bool r333227 = r333223 <= r333226;
        double r333228 = !r333227;
        bool r333229 = r333225 || r333228;
        double r333230 = x;
        double r333231 = y;
        double r333232 = sin(r333231);
        double r333233 = r333231 / r333232;
        double r333234 = r333230 / r333233;
        double r333235 = 1.0;
        double r333236 = r333235 / r333223;
        double r333237 = r333234 * r333236;
        double r333238 = r333232 / r333231;
        double r333239 = r333223 / r333238;
        double r333240 = r333230 / r333239;
        double r333241 = r333229 ? r333237 : r333240;
        return r333241;
}

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.8
Target0.3
Herbie0.5
\[\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.5580377679133428e+92 or 5.039220706859192e+68 < z

    1. Initial program 0.1

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{\frac{\sin y}{y}}{z}\]
    6. Using strategy rm
    7. Applied clear-num6.0

      \[\leadsto x \cdot \frac{\color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}\]
    8. Using strategy rm
    9. Applied div-inv6.0

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{\frac{y}{\sin y}} \cdot \frac{1}{z}\right)}\]
    10. Applied associate-*r*0.2

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

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

    if -1.5580377679133428e+92 < z < 5.039220706859192e+68

    1. Initial program 4.5

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

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

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

Reproduce

herbie shell --seed 2019235 +o rules:numerics
(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))