Average Error: 2.6 → 0.3
Time: 4.5s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \le -2.155566547691587058014765982566123084784 \cdot 10^{-290} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.212547594237189431415383106313707223784 \cdot 10^{-152}\right):\\ \;\;\;\;\frac{1 \cdot \left(x \cdot \frac{1}{\frac{y}{\sin y}}\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \cdot \frac{\sin y}{y} \le -2.155566547691587058014765982566123084784 \cdot 10^{-290} \lor \neg \left(x \cdot \frac{\sin y}{y} \le 2.212547594237189431415383106313707223784 \cdot 10^{-152}\right):\\
\;\;\;\;\frac{1 \cdot \left(x \cdot \frac{1}{\frac{y}{\sin y}}\right)}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r399824 = x;
        double r399825 = y;
        double r399826 = sin(r399825);
        double r399827 = r399826 / r399825;
        double r399828 = r399824 * r399827;
        double r399829 = z;
        double r399830 = r399828 / r399829;
        return r399830;
}

double f(double x, double y, double z) {
        double r399831 = x;
        double r399832 = y;
        double r399833 = sin(r399832);
        double r399834 = r399833 / r399832;
        double r399835 = r399831 * r399834;
        double r399836 = -2.155566547691587e-290;
        bool r399837 = r399835 <= r399836;
        double r399838 = 2.2125475942371894e-152;
        bool r399839 = r399835 <= r399838;
        double r399840 = !r399839;
        bool r399841 = r399837 || r399840;
        double r399842 = 1.0;
        double r399843 = r399832 / r399833;
        double r399844 = r399842 / r399843;
        double r399845 = r399831 * r399844;
        double r399846 = r399842 * r399845;
        double r399847 = z;
        double r399848 = r399846 / r399847;
        double r399849 = r399847 / r399834;
        double r399850 = r399831 / r399849;
        double r399851 = r399841 ? r399848 : r399850;
        return r399851;
}

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.3
\[\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)) < -2.155566547691587e-290 or 2.2125475942371894e-152 < (* x (/ (sin y) y))

    1. Initial program 0.2

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

      \[\leadsto \frac{x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}}}{z}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.2

      \[\leadsto \frac{\color{blue}{\left(1 \cdot x\right)} \cdot \frac{1}{\frac{y}{\sin y}}}{z}\]
    6. Applied associate-*l*0.2

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

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

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

    if -2.155566547691587e-290 < (* x (/ (sin y) y)) < 2.2125475942371894e-152

    1. Initial program 8.7

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*0.6

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

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

Reproduce

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