Average Error: 7.8 → 0.4
Time: 6.1s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -261095818.6417586803436279296875:\\ \;\;\;\;\left(\cosh x \cdot y\right) \cdot \frac{\frac{1}{x}}{z}\\ \mathbf{elif}\;z \le 60.4393804861111334503220859915018081665:\\ \;\;\;\;\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -261095818.6417586803436279296875:\\
\;\;\;\;\left(\cosh x \cdot y\right) \cdot \frac{\frac{1}{x}}{z}\\

\mathbf{elif}\;z \le 60.4393804861111334503220859915018081665:\\
\;\;\;\;\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r618041 = x;
        double r618042 = cosh(r618041);
        double r618043 = y;
        double r618044 = r618043 / r618041;
        double r618045 = r618042 * r618044;
        double r618046 = z;
        double r618047 = r618045 / r618046;
        return r618047;
}

double f(double x, double y, double z) {
        double r618048 = z;
        double r618049 = -261095818.64175868;
        bool r618050 = r618048 <= r618049;
        double r618051 = x;
        double r618052 = cosh(r618051);
        double r618053 = y;
        double r618054 = r618052 * r618053;
        double r618055 = 1.0;
        double r618056 = r618055 / r618051;
        double r618057 = r618056 / r618048;
        double r618058 = r618054 * r618057;
        double r618059 = 60.43938048611113;
        bool r618060 = r618048 <= r618059;
        double r618061 = r618054 * r618056;
        double r618062 = r618061 / r618048;
        double r618063 = r618048 * r618051;
        double r618064 = r618054 / r618063;
        double r618065 = r618060 ? r618062 : r618064;
        double r618066 = r618050 ? r618058 : r618065;
        return r618066;
}

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

Original7.8
Target0.4
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;y \lt -4.618902267687041990497740832940559043667 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y \lt 1.038530535935152855236908684227749499669 \cdot 10^{-39}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -261095818.64175868

    1. Initial program 12.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied div-inv12.3

      \[\leadsto \frac{\cosh x \cdot \color{blue}{\left(y \cdot \frac{1}{x}\right)}}{z}\]
    4. Applied associate-*r*12.3

      \[\leadsto \frac{\color{blue}{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}}{z}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity12.3

      \[\leadsto \frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}{\color{blue}{1 \cdot z}}\]
    7. Applied times-frac0.4

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{1} \cdot \frac{\frac{1}{x}}{z}}\]
    8. Simplified0.4

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

    if -261095818.64175868 < z < 60.43938048611113

    1. Initial program 0.3

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

      \[\leadsto \frac{\cosh x \cdot \color{blue}{\left(y \cdot \frac{1}{x}\right)}}{z}\]
    4. Applied associate-*r*0.4

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

    if 60.43938048611113 < z

    1. Initial program 11.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -261095818.6417586803436279296875:\\ \;\;\;\;\left(\cosh x \cdot y\right) \cdot \frac{\frac{1}{x}}{z}\\ \mathbf{elif}\;z \le 60.4393804861111334503220859915018081665:\\ \;\;\;\;\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019354 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$ctan from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.0385305359351529e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))

  (/ (* (cosh x) (/ y x)) z))