Average Error: 2.6 → 0.2
Time: 18.2s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.462011006316163372763567222352753676202 \cdot 10^{-19}:\\ \;\;\;\;\frac{\left(\frac{1}{y} \cdot \sin y\right) \cdot x}{z}\\ \mathbf{elif}\;z \le 68807179613763876432117760:\\ \;\;\;\;\frac{x}{\frac{y}{\sin y} \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{1}{y} \cdot \sin y\right) \cdot x}{z}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -4.462011006316163372763567222352753676202 \cdot 10^{-19}:\\
\;\;\;\;\frac{\left(\frac{1}{y} \cdot \sin y\right) \cdot x}{z}\\

\mathbf{elif}\;z \le 68807179613763876432117760:\\
\;\;\;\;\frac{x}{\frac{y}{\sin y} \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{y} \cdot \sin y\right) \cdot x}{z}\\

\end{array}
double f(double x, double y, double z) {
        double r27018612 = x;
        double r27018613 = y;
        double r27018614 = sin(r27018613);
        double r27018615 = r27018614 / r27018613;
        double r27018616 = r27018612 * r27018615;
        double r27018617 = z;
        double r27018618 = r27018616 / r27018617;
        return r27018618;
}

double f(double x, double y, double z) {
        double r27018619 = z;
        double r27018620 = -4.462011006316163e-19;
        bool r27018621 = r27018619 <= r27018620;
        double r27018622 = 1.0;
        double r27018623 = y;
        double r27018624 = r27018622 / r27018623;
        double r27018625 = sin(r27018623);
        double r27018626 = r27018624 * r27018625;
        double r27018627 = x;
        double r27018628 = r27018626 * r27018627;
        double r27018629 = r27018628 / r27018619;
        double r27018630 = 6.880717961376388e+25;
        bool r27018631 = r27018619 <= r27018630;
        double r27018632 = r27018623 / r27018625;
        double r27018633 = r27018632 * r27018619;
        double r27018634 = r27018627 / r27018633;
        double r27018635 = r27018631 ? r27018634 : r27018629;
        double r27018636 = r27018621 ? r27018629 : r27018635;
        return r27018636;
}

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 z < -4.462011006316163e-19 or 6.880717961376388e+25 < z

    1. Initial program 0.1

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

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

    if -4.462011006316163e-19 < z < 6.880717961376388e+25

    1. Initial program 5.4

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.462011006316163372763567222352753676202 \cdot 10^{-19}:\\ \;\;\;\;\frac{\left(\frac{1}{y} \cdot \sin y\right) \cdot x}{z}\\ \mathbf{elif}\;z \le 68807179613763876432117760:\\ \;\;\;\;\frac{x}{\frac{y}{\sin y} \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{1}{y} \cdot \sin y\right) \cdot x}{z}\\ \end{array}\]

Reproduce

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

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

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