Average Error: 2.6 → 0.3
Time: 13.7s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.087165816385635344943339840209275513753 \cdot 10^{-13} \lor \neg \left(z \le 9.627811326025673289997350667394252252108 \cdot 10^{-38}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sin y}{z}}{y} \cdot x\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.087165816385635344943339840209275513753 \cdot 10^{-13} \lor \neg \left(z \le 9.627811326025673289997350667394252252108 \cdot 10^{-38}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r445900 = x;
        double r445901 = y;
        double r445902 = sin(r445901);
        double r445903 = r445902 / r445901;
        double r445904 = r445900 * r445903;
        double r445905 = z;
        double r445906 = r445904 / r445905;
        return r445906;
}

double f(double x, double y, double z) {
        double r445907 = z;
        double r445908 = -1.0871658163856353e-13;
        bool r445909 = r445907 <= r445908;
        double r445910 = 9.627811326025673e-38;
        bool r445911 = r445907 <= r445910;
        double r445912 = !r445911;
        bool r445913 = r445909 || r445912;
        double r445914 = y;
        double r445915 = sin(r445914);
        double r445916 = r445915 / r445914;
        double r445917 = x;
        double r445918 = r445917 / r445907;
        double r445919 = r445916 * r445918;
        double r445920 = r445915 / r445907;
        double r445921 = r445920 / r445914;
        double r445922 = r445921 * r445917;
        double r445923 = r445913 ? r445919 : r445922;
        return r445923;
}

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 z < -1.0871658163856353e-13 or 9.627811326025673e-38 < z

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{\sin y}{y}}{z}}\]
    3. Taylor expanded around inf 7.6

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

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

    if -1.0871658163856353e-13 < z < 9.627811326025673e-38

    1. Initial program 5.9

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

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

      \[\leadsto x \cdot \frac{\frac{\sin y}{y}}{\color{blue}{1 \cdot z}}\]
    5. Applied *-un-lft-identity0.3

      \[\leadsto x \cdot \frac{\frac{\sin y}{\color{blue}{1 \cdot y}}}{1 \cdot z}\]
    6. Applied *-un-lft-identity0.3

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.087165816385635344943339840209275513753 \cdot 10^{-13} \lor \neg \left(z \le 9.627811326025673289997350667394252252108 \cdot 10^{-38}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sin y}{z}}{y} \cdot x\\ \end{array}\]

Reproduce

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