Average Error: 2.7 → 0.5
Time: 3.8s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2479862814516639666704126424950104915968 \lor \neg \left(z \le 1.160267119765981524200153949151163454122 \cdot 10^{108}\right):\\ \;\;\;\;\left(\frac{\sin y}{y} \cdot x\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{\sin y}{y}}{z}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -2479862814516639666704126424950104915968 \lor \neg \left(z \le 1.160267119765981524200153949151163454122 \cdot 10^{108}\right):\\
\;\;\;\;\left(\frac{\sin y}{y} \cdot x\right) \cdot \frac{1}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r457939 = x;
        double r457940 = y;
        double r457941 = sin(r457940);
        double r457942 = r457941 / r457940;
        double r457943 = r457939 * r457942;
        double r457944 = z;
        double r457945 = r457943 / r457944;
        return r457945;
}

double f(double x, double y, double z) {
        double r457946 = z;
        double r457947 = -2.4798628145166397e+39;
        bool r457948 = r457946 <= r457947;
        double r457949 = 1.1602671197659815e+108;
        bool r457950 = r457946 <= r457949;
        double r457951 = !r457950;
        bool r457952 = r457948 || r457951;
        double r457953 = y;
        double r457954 = sin(r457953);
        double r457955 = r457954 / r457953;
        double r457956 = x;
        double r457957 = r457955 * r457956;
        double r457958 = 1.0;
        double r457959 = r457958 / r457946;
        double r457960 = r457957 * r457959;
        double r457961 = r457955 / r457946;
        double r457962 = r457956 * r457961;
        double r457963 = r457952 ? r457960 : r457962;
        return r457963;
}

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.5
\[\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 < -2.4798628145166397e+39 or 1.1602671197659815e+108 < z

    1. Initial program 0.1

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied *-commutative0.1

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

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

    if -2.4798628145166397e+39 < z < 1.1602671197659815e+108

    1. Initial program 4.5

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity4.5

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

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

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

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

Reproduce

herbie shell --seed 2020001 +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))