Average Error: 2.7 → 0.3
Time: 18.5s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \cdot x \le -1.794335516845841475026763291211245703492 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin y}{y}\right)\right)}{z}\\ \mathbf{elif}\;\frac{\sin y}{y} \cdot x \le 8.450034510697123808431823271123881050474 \cdot 10^{-302}:\\ \;\;\;\;\frac{x \cdot \sin y}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin y}{y}\right)\right)}{z}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \cdot x \le -1.794335516845841475026763291211245703492 \cdot 10^{-304}:\\
\;\;\;\;\frac{x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin y}{y}\right)\right)}{z}\\

\mathbf{elif}\;\frac{\sin y}{y} \cdot x \le 8.450034510697123808431823271123881050474 \cdot 10^{-302}:\\
\;\;\;\;\frac{x \cdot \sin y}{z \cdot y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin y}{y}\right)\right)}{z}\\

\end{array}
double f(double x, double y, double z) {
        double r25993014 = x;
        double r25993015 = y;
        double r25993016 = sin(r25993015);
        double r25993017 = r25993016 / r25993015;
        double r25993018 = r25993014 * r25993017;
        double r25993019 = z;
        double r25993020 = r25993018 / r25993019;
        return r25993020;
}

double f(double x, double y, double z) {
        double r25993021 = y;
        double r25993022 = sin(r25993021);
        double r25993023 = r25993022 / r25993021;
        double r25993024 = x;
        double r25993025 = r25993023 * r25993024;
        double r25993026 = -1.7943355168458415e-304;
        bool r25993027 = r25993025 <= r25993026;
        double r25993028 = log1p(r25993023);
        double r25993029 = expm1(r25993028);
        double r25993030 = r25993024 * r25993029;
        double r25993031 = z;
        double r25993032 = r25993030 / r25993031;
        double r25993033 = 8.450034510697124e-302;
        bool r25993034 = r25993025 <= r25993033;
        double r25993035 = r25993024 * r25993022;
        double r25993036 = r25993031 * r25993021;
        double r25993037 = r25993035 / r25993036;
        double r25993038 = r25993034 ? r25993037 : r25993032;
        double r25993039 = r25993027 ? r25993032 : r25993038;
        return r25993039;
}

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 (/ (sin y) y)) < -1.7943355168458415e-304 or 8.450034510697124e-302 < (* x (/ (sin y) y))

    1. Initial program 0.2

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u0.2

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

    if -1.7943355168458415e-304 < (* x (/ (sin y) y)) < 8.450034510697124e-302

    1. Initial program 17.4

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

      \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z}\]
    4. Applied associate-/l/1.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \cdot x \le -1.794335516845841475026763291211245703492 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin y}{y}\right)\right)}{z}\\ \mathbf{elif}\;\frac{\sin y}{y} \cdot x \le 8.450034510697123808431823271123881050474 \cdot 10^{-302}:\\ \;\;\;\;\frac{x \cdot \sin y}{z \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin y}{y}\right)\right)}{z}\\ \end{array}\]

Reproduce

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