Average Error: 2.8 → 1.6
Time: 15.9s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.800510743519484350282777849822879765183 \cdot 10^{60}:\\ \;\;\;\;\frac{\frac{\sin y}{y} \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y \cdot \frac{1}{y}}{z} \cdot x\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \le -1.800510743519484350282777849822879765183 \cdot 10^{60}:\\
\;\;\;\;\frac{\frac{\sin y}{y} \cdot x}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r353039 = x;
        double r353040 = y;
        double r353041 = sin(r353040);
        double r353042 = r353041 / r353040;
        double r353043 = r353039 * r353042;
        double r353044 = z;
        double r353045 = r353043 / r353044;
        return r353045;
}

double f(double x, double y, double z) {
        double r353046 = x;
        double r353047 = -1.8005107435194844e+60;
        bool r353048 = r353046 <= r353047;
        double r353049 = y;
        double r353050 = sin(r353049);
        double r353051 = r353050 / r353049;
        double r353052 = r353051 * r353046;
        double r353053 = z;
        double r353054 = r353052 / r353053;
        double r353055 = 1.0;
        double r353056 = r353055 / r353049;
        double r353057 = r353050 * r353056;
        double r353058 = r353057 / r353053;
        double r353059 = r353058 * r353046;
        double r353060 = r353048 ? r353054 : r353059;
        return r353060;
}

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
Herbie1.6
\[\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 < -1.8005107435194844e+60

    1. Initial program 0.2

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Simplified8.3

      \[\leadsto \color{blue}{x \cdot \frac{\frac{\sin y}{y}}{z}}\]
    3. Using strategy rm
    4. Applied div-inv8.3

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

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

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

    if -1.8005107435194844e+60 < x

    1. Initial program 3.3

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Simplified1.9

      \[\leadsto \color{blue}{x \cdot \frac{\frac{\sin y}{y}}{z}}\]
    3. Using strategy rm
    4. Applied div-inv1.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.800510743519484350282777849822879765183 \cdot 10^{60}:\\ \;\;\;\;\frac{\frac{\sin y}{y} \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y \cdot \frac{1}{y}}{z} \cdot x\\ \end{array}\]

Reproduce

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