Average Error: 2.6 → 0.2
Time: 17.0s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \frac{\sin y}{y}}{z} \le -4.858142113209716248741580753458932503207 \cdot 10^{71} \lor \neg \left(\frac{x \cdot \frac{\sin y}{y}}{z} \le 5.697804217889548334579144506228942645976 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \frac{\sin y}{y}}{z} \le -4.858142113209716248741580753458932503207 \cdot 10^{71} \lor \neg \left(\frac{x \cdot \frac{\sin y}{y}}{z} \le 5.697804217889548334579144506228942645976 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r282926 = x;
        double r282927 = y;
        double r282928 = sin(r282927);
        double r282929 = r282928 / r282927;
        double r282930 = r282926 * r282929;
        double r282931 = z;
        double r282932 = r282930 / r282931;
        return r282932;
}

double f(double x, double y, double z) {
        double r282933 = x;
        double r282934 = y;
        double r282935 = sin(r282934);
        double r282936 = r282935 / r282934;
        double r282937 = r282933 * r282936;
        double r282938 = z;
        double r282939 = r282937 / r282938;
        double r282940 = -4.858142113209716e+71;
        bool r282941 = r282939 <= r282940;
        double r282942 = 5.697804217889548e-06;
        bool r282943 = r282939 <= r282942;
        double r282944 = !r282943;
        bool r282945 = r282941 || r282944;
        double r282946 = r282934 / r282935;
        double r282947 = r282938 * r282946;
        double r282948 = r282933 / r282947;
        double r282949 = r282933 / r282938;
        double r282950 = r282936 * r282949;
        double r282951 = r282945 ? r282948 : r282950;
        return r282951;
}

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.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 2 regimes
  2. if (/ (* x (/ (sin y) y)) z) < -4.858142113209716e+71 or 5.697804217889548e-06 < (/ (* x (/ (sin y) y)) z)

    1. Initial program 0.2

      \[\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.2

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

    if -4.858142113209716e+71 < (/ (* x (/ (sin y) y)) z) < 5.697804217889548e-06

    1. Initial program 3.6

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right) \cdot \sqrt[3]{\frac{\sin y}{y}}\right)}}{z}\]
    4. Using strategy rm
    5. Applied div-inv4.0

      \[\leadsto \color{blue}{\left(x \cdot \left(\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right) \cdot \sqrt[3]{\frac{\sin y}{y}}\right)\right) \cdot \frac{1}{z}}\]
    6. Using strategy rm
    7. Applied pow14.0

      \[\leadsto \left(x \cdot \left(\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right) \cdot \sqrt[3]{\frac{\sin y}{y}}\right)\right) \cdot \color{blue}{{\left(\frac{1}{z}\right)}^{1}}\]
    8. Applied pow14.0

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

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

      \[\leadsto \left(x \cdot \left(\left(\color{blue}{{\left(\sqrt[3]{\frac{\sin y}{y}}\right)}^{1}} \cdot {\left(\sqrt[3]{\frac{\sin y}{y}}\right)}^{1}\right) \cdot {\left(\sqrt[3]{\frac{\sin y}{y}}\right)}^{1}\right)\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    11. Applied pow-prod-down4.0

      \[\leadsto \left(x \cdot \left(\color{blue}{{\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right)}^{1}} \cdot {\left(\sqrt[3]{\frac{\sin y}{y}}\right)}^{1}\right)\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    12. Applied pow-prod-down4.0

      \[\leadsto \left(x \cdot \color{blue}{{\left(\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right) \cdot \sqrt[3]{\frac{\sin y}{y}}\right)}^{1}}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    13. Applied pow14.0

      \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {\left(\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right) \cdot \sqrt[3]{\frac{\sin y}{y}}\right)}^{1}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    14. Applied pow-prod-down4.0

      \[\leadsto \color{blue}{{\left(x \cdot \left(\left(\sqrt[3]{\frac{\sin y}{y}} \cdot \sqrt[3]{\frac{\sin y}{y}}\right) \cdot \sqrt[3]{\frac{\sin y}{y}}\right)\right)}^{1}} \cdot {\left(\frac{1}{z}\right)}^{1}\]
    15. Applied pow-prod-down4.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \frac{\sin y}{y}}{z} \le -4.858142113209716248741580753458932503207 \cdot 10^{71} \lor \neg \left(\frac{x \cdot \frac{\sin y}{y}}{z} \le 5.697804217889548334579144506228942645976 \cdot 10^{-6}\right):\\ \;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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