Average Error: 2.7 → 0.3
Time: 4.6s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1689746151164735731134924526336755105792 \lor \neg \left(x \le 3.65008048955020314402416831939325420996 \cdot 10^{-75}\right):\\ \;\;\;\;\frac{x \cdot \left(\sin y \cdot \frac{1}{y}\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{\sin y}{y}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \le -1689746151164735731134924526336755105792 \lor \neg \left(x \le 3.65008048955020314402416831939325420996 \cdot 10^{-75}\right):\\
\;\;\;\;\frac{x \cdot \left(\sin y \cdot \frac{1}{y}\right)}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r504002 = x;
        double r504003 = y;
        double r504004 = sin(r504003);
        double r504005 = r504004 / r504003;
        double r504006 = r504002 * r504005;
        double r504007 = z;
        double r504008 = r504006 / r504007;
        return r504008;
}

double f(double x, double y, double z) {
        double r504009 = x;
        double r504010 = -1.6897461511647357e+39;
        bool r504011 = r504009 <= r504010;
        double r504012 = 3.650080489550203e-75;
        bool r504013 = r504009 <= r504012;
        double r504014 = !r504013;
        bool r504015 = r504011 || r504014;
        double r504016 = y;
        double r504017 = sin(r504016);
        double r504018 = 1.0;
        double r504019 = r504018 / r504016;
        double r504020 = r504017 * r504019;
        double r504021 = r504009 * r504020;
        double r504022 = z;
        double r504023 = r504021 / r504022;
        double r504024 = r504009 / r504022;
        double r504025 = r504017 / r504016;
        double r504026 = r504024 * r504025;
        double r504027 = r504015 ? r504023 : r504026;
        return r504027;
}

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.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 < -1.6897461511647357e+39 or 3.650080489550203e-75 < x

    1. Initial program 0.4

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

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

    if -1.6897461511647357e+39 < x < 3.650080489550203e-75

    1. Initial program 4.8

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.2

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

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

Reproduce

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