Average Error: 2.7 → 0.2
Time: 3.8s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \le -2.2420082536324771 \cdot 10^{-303} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.53370143623 \cdot 10^{-314}\right):\\ \;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot \sin y}{z}}{y}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot \frac{\sin y}{y} \le -2.2420082536324771 \cdot 10^{-303} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.53370143623 \cdot 10^{-314}\right):\\
\;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r658888 = x;
        double r658889 = y;
        double r658890 = sin(r658889);
        double r658891 = r658890 / r658889;
        double r658892 = r658888 * r658891;
        double r658893 = z;
        double r658894 = r658892 / r658893;
        return r658894;
}

double f(double x, double y, double z) {
        double r658895 = x;
        double r658896 = y;
        double r658897 = sin(r658896);
        double r658898 = r658897 / r658896;
        double r658899 = r658895 * r658898;
        double r658900 = -2.242008253632477e-303;
        bool r658901 = r658899 <= r658900;
        double r658902 = 2.5337014362254e-314;
        bool r658903 = r658899 <= r658902;
        double r658904 = !r658903;
        bool r658905 = r658901 || r658904;
        double r658906 = z;
        double r658907 = r658899 / r658906;
        double r658908 = r658895 * r658897;
        double r658909 = r658908 / r658906;
        double r658910 = r658909 / r658896;
        double r658911 = r658905 ? r658907 : r658910;
        return r658911;
}

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.2
\[\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 (* x (/ (sin y) y)) < -2.242008253632477e-303 or 2.5337014362254e-314 < (* x (/ (sin y) y))

    1. Initial program 0.2

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]

    if -2.242008253632477e-303 < (* x (/ (sin y) y)) < 2.5337014362254e-314

    1. Initial program 17.9

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \le -2.2420082536324771 \cdot 10^{-303} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.53370143623 \cdot 10^{-314}\right):\\ \;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot \sin y}{z}}{y}\\ \end{array}\]

Reproduce

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