Average Error: 2.6 → 0.3
Time: 6.1s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.07914030231644789 \cdot 10^{32} \lor \neg \left(z \le 9.91958923133224245 \cdot 10^{38}\right):\\ \;\;\;\;\left(x \cdot \left(1 \cdot \frac{\sin y}{y}\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.07914030231644789 \cdot 10^{32} \lor \neg \left(z \le 9.91958923133224245 \cdot 10^{38}\right):\\
\;\;\;\;\left(x \cdot \left(1 \cdot \frac{\sin y}{y}\right)\right) \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r518823 = x;
        double r518824 = y;
        double r518825 = sin(r518824);
        double r518826 = r518825 / r518824;
        double r518827 = r518823 * r518826;
        double r518828 = z;
        double r518829 = r518827 / r518828;
        return r518829;
}

double f(double x, double y, double z) {
        double r518830 = z;
        double r518831 = -1.0791403023164479e+32;
        bool r518832 = r518830 <= r518831;
        double r518833 = 9.919589231332242e+38;
        bool r518834 = r518830 <= r518833;
        double r518835 = !r518834;
        bool r518836 = r518832 || r518835;
        double r518837 = x;
        double r518838 = 1.0;
        double r518839 = y;
        double r518840 = sin(r518839);
        double r518841 = r518840 / r518839;
        double r518842 = r518838 * r518841;
        double r518843 = r518837 * r518842;
        double r518844 = r518838 / r518830;
        double r518845 = r518843 * r518844;
        double r518846 = r518839 / r518840;
        double r518847 = r518830 * r518846;
        double r518848 = r518837 / r518847;
        double r518849 = r518836 ? r518845 : r518848;
        return r518849;
}

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.3
\[\begin{array}{l} \mathbf{if}\;z \lt -4.21737202034271466 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \mathbf{elif}\;z \lt 4.44670236911381103 \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.0791403023164479e+32 or 9.919589231332242e+38 < z

    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 *-un-lft-identity0.1

      \[\leadsto \frac{x \cdot \frac{1}{\frac{y}{\color{blue}{1 \cdot \sin y}}}}{z}\]
    6. Applied *-un-lft-identity0.1

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

      \[\leadsto \frac{x \cdot \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{y}{\sin y}}}}{z}\]
    8. Applied add-cube-cbrt0.1

      \[\leadsto \frac{x \cdot \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{y}{\sin y}}}{z}\]
    9. Applied times-frac0.1

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

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

      \[\leadsto \frac{x \cdot \left(1 \cdot \color{blue}{\frac{\sin y}{y}}\right)}{z}\]
    12. Using strategy rm
    13. Applied div-inv0.2

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

    if -1.0791403023164479e+32 < z < 9.919589231332242e+38

    1. Initial program 4.9

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

      \[\leadsto \frac{x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}\]
    4. Using strategy rm
    5. Applied associate-/l*0.3

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

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

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

Reproduce

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

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

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